xref: /PHP-8.3/ext/opcache/tests/jit/mod_002.phpt (revision e9f783fc)
1--TEST--
2JIT MOD: 002
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.jit_buffer_size=1M
8opcache.protect_memory=1
9--EXTENSIONS--
10opcache
11--FILE--
12<?php
13function mod33(int $a) {
14    return $a % 33;
15}
16function mod32(int $a) {
17    return $a % 32;
18}
19function modNeg33(int $a) {
20    return $a % -33;
21}
22function modNeg1(int $a) {
23    return $a % -1;
24}
25function mod0(int $a) {
26    return $a % 0;
27}
28var_dump(mod33(125));
29var_dump(mod32(125));
30var_dump(mod33(-125));
31var_dump(mod32(-125));
32var_dump(modNeg33(125));
33var_dump(modNeg33(-125));
34try {
35    var_dump(modNeg1(125));
36} catch (Throwable $e) {
37    echo "Exception " . $e->getMessage() . "\n";
38}
39try {
40    var_dump(mod0(125));
41} catch (Throwable $e) {
42    echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n";
43}
44?>
45--EXPECT--
46int(26)
47int(29)
48int(-26)
49int(-29)
50int(26)
51int(-26)
52int(0)
53Exception (DivisionByZeroError): Modulo by zero
54