043.phpt 776 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Match expression error messages
  3. --FILE--
  4. <?php
  5. class Beep {}
  6. function test(mixed $var) {
  7. try {
  8. match($var) {};
  9. } catch (UnhandledMatchError $e) {
  10. print $e->getMessage() . PHP_EOL;
  11. }
  12. }
  13. test(null);
  14. test(1);
  15. test(5.5);
  16. test(5.0);
  17. test("foo");
  18. test(true);
  19. test(false);
  20. test([1, 2, 3]);
  21. test(new Beep());
  22. // Testing long strings.
  23. test(str_repeat('e', 100));
  24. test(str_repeat("e\n", 100));
  25. ?>
  26. --EXPECT--
  27. Unhandled match case NULL
  28. Unhandled match case 1
  29. Unhandled match case 5.5
  30. Unhandled match case 5.0
  31. Unhandled match case 'foo'
  32. Unhandled match case true
  33. Unhandled match case false
  34. Unhandled match case of type array
  35. Unhandled match case of type Beep
  36. Unhandled match case 'eeeeeeeeeeeeeee...'
  37. Unhandled match case 'e\ne\ne\ne\ne\ne\ne\ne...'