xref: /PHP-8.3/ext/opcache/tests/jit/nan_002.phpt (revision 8a087302)
1--TEST--
2NaN handling: 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--FILE--
10<?php
11function test(float $a) {
12    if ($a) var_dump("1");
13    if (!$a) var_dump("2");
14    var_dump((bool) $a);
15    var_dump(!$a);
16    echo "\n";
17}
18function test1(float $a, bool $b) {
19    var_dump($a && $b); //JMPNZ_EX
20}
21function test2(float $a, bool $b) {
22    var_dump($a || $b); // JMPZ_EX
23}
24test(NAN);
25test(1.0);
26test(0.0);
27
28test1(NAN, true);
29test1(1.0, true);
30test1(0.0, true);
31echo "\n";
32
33test2(NAN, false);
34test2(1.0, false);
35test2(0.0, false);
36?>
37--EXPECT--
38string(1) "1"
39bool(true)
40bool(false)
41
42string(1) "1"
43bool(true)
44bool(false)
45
46string(1) "2"
47bool(false)
48bool(true)
49
50bool(true)
51bool(true)
52bool(false)
53
54bool(true)
55bool(true)
56bool(false)
57