002.phpt 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test match jump table optimizer
  3. --INI--
  4. opcache.enable=1
  5. opcache.enable_cli=1
  6. opcache.opt_debug_level=0x20000
  7. --EXTENSIONS--
  8. opcache
  9. --FILE--
  10. <?php
  11. function test() {
  12. $x = '2';
  13. echo match($x) {
  14. 1, 2, 3, 4, 5 => throw new RuntimeException(),
  15. default => "No match\n",
  16. };
  17. }
  18. test();
  19. function test2() {
  20. $x = 2;
  21. echo match($x) {
  22. '1', '2', '3', '4', '5' => throw new RuntimeException(),
  23. default => "No match\n",
  24. };
  25. }
  26. test2();
  27. ?>
  28. --EXPECTF--
  29. $_main:
  30. ; (lines=5, args=0, vars=0, tmps=0)
  31. ; (after optimizer)
  32. ; %s
  33. 0000 INIT_FCALL 0 %d string("test")
  34. 0001 DO_UCALL
  35. 0002 INIT_FCALL 0 %d string("test2")
  36. 0003 DO_UCALL
  37. 0004 RETURN int(1)
  38. test:
  39. ; (lines=2, args=0, vars=0, tmps=0)
  40. ; (after optimizer)
  41. ; %s
  42. 0000 ECHO string("No match
  43. ")
  44. 0001 RETURN null
  45. test2:
  46. ; (lines=2, args=0, vars=0, tmps=0)
  47. ; (after optimizer)
  48. ; %s
  49. 0000 ECHO string("No match
  50. ")
  51. 0001 RETURN null
  52. No match
  53. No match