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