xref: /php-src/ext/opcache/tests/jit/mod_001.phpt (revision c16ad918)
1--TEST--
2JIT MOD: 001
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.protect_memory=1
8--EXTENSIONS--
9opcache
10--FILE--
11<?php
12function mod(int $a, int $b) {
13    return $a % $b;
14}
15var_dump(mod(125, 33));
16var_dump(mod(125, 32));
17var_dump(mod(-125, 33));
18var_dump(mod(-125, 32));
19var_dump(mod(125, -33));
20var_dump(mod(-125, -33));
21try {
22    var_dump(mod(125, -1));
23} catch (Throwable $e) {
24    echo "Exception " . $e->getMessage() . "\n";
25}
26try {
27    var_dump(mod(125, 0));
28} catch (Throwable $e) {
29    echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n";
30}
31?>
32--EXPECT--
33int(26)
34int(29)
35int(-26)
36int(-29)
37int(26)
38int(-26)
39int(0)
40Exception (DivisionByZeroError): Modulo by zero
41