xref: /PHP-8.4/ext/opcache/tests/jit/mod_002.phpt (revision c16ad918)
1--TEST--
2JIT MOD: 002
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 mod33(int $a) {
13    return $a % 33;
14}
15function mod32(int $a) {
16    return $a % 32;
17}
18function modNeg33(int $a) {
19    return $a % -33;
20}
21function modNeg1(int $a) {
22    return $a % -1;
23}
24function mod0(int $a) {
25    return $a % 0;
26}
27var_dump(mod33(125));
28var_dump(mod32(125));
29var_dump(mod33(-125));
30var_dump(mod32(-125));
31var_dump(modNeg33(125));
32var_dump(modNeg33(-125));
33try {
34    var_dump(modNeg1(125));
35} catch (Throwable $e) {
36    echo "Exception " . $e->getMessage() . "\n";
37}
38try {
39    var_dump(mod0(125));
40} catch (Throwable $e) {
41    echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n";
42}
43?>
44--EXPECT--
45int(26)
46int(29)
47int(-26)
48int(-29)
49int(26)
50int(-26)
51int(0)
52Exception (DivisionByZeroError): Modulo by zero
53