nan_002.phpt 820 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. NaN handling: 002
  3. --INI--
  4. opcache.enable=1
  5. opcache.enable_cli=1
  6. opcache.file_update_protection=0
  7. opcache.jit_buffer_size=1M
  8. opcache.protect_memory=1
  9. --FILE--
  10. <?php
  11. function 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. }
  18. function test1(float $a, bool $b) {
  19. var_dump($a && $b); //JMPNZ_EX
  20. }
  21. function test2(float $a, bool $b) {
  22. var_dump($a || $b); // JMPZ_EX
  23. }
  24. test(NAN);
  25. test(1.0);
  26. test(0.0);
  27. test1(NAN, true);
  28. test1(1.0, true);
  29. test1(0.0, true);
  30. echo "\n";
  31. test2(NAN, false);
  32. test2(1.0, false);
  33. test2(0.0, false);
  34. ?>
  35. --EXPECT--
  36. string(1) "1"
  37. bool(true)
  38. bool(false)
  39. string(1) "1"
  40. bool(true)
  41. bool(false)
  42. string(1) "2"
  43. bool(false)
  44. bool(true)
  45. bool(true)
  46. bool(true)
  47. bool(false)
  48. bool(true)
  49. bool(true)
  50. bool(false)