diff options
Diffstat (limited to 'Zend/tests/match/037.phpt')
-rw-r--r-- | Zend/tests/match/037.phpt | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Zend/tests/match/037.phpt b/Zend/tests/match/037.phpt new file mode 100644 index 0000000000..e114696f5f --- /dev/null +++ b/Zend/tests/match/037.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test match jumptable with only one arm +--FILE-- +<?php + +try { + var_dump(match(true) { + 1, 2, 3, 4, 5 => 'foo', + }); +} catch (Error $e) { + var_dump((string) $e); +} + +try { + var_dump(match(6) { + 1, 2, 3, 4, 5 => 'foo', + }); +} catch (Error $e) { + var_dump((string) $e); +} + +try { + var_dump(match('3') { + 1, 2, 3, 4, 5 => 'foo', + }); +} catch (Error $e) { + var_dump((string) $e); +} + +var_dump(match(3) { + 1, 2, 3, 4, 5 => 'foo', +}); + +var_dump(match(true) { + 1, 2, 3, 4, 5 => 'foo', + default => 'bar', +}); + +var_dump(match(6) { + 1, 2, 3, 4, 5 => 'foo', + default => 'bar', +}); + +var_dump(match('3') { + 1, 2, 3, 4, 5 => 'foo', + default => 'bar', +}); + +var_dump(match(3) { + 1, 2, 3, 4, 5 => 'foo', + default => 'bar', +}); + +--EXPECTF-- +string(%d) "UnhandledMatchError: Unhandled match value of type bool in %s037.php:5 +Stack trace: +#0 {main}" +string(%d) "UnhandledMatchError: Unhandled match value of type int in %s037.php:13 +Stack trace: +#0 {main}" +string(%d) "UnhandledMatchError: Unhandled match value of type string in %s037.php:21 +Stack trace: +#0 {main}" +string(3) "foo" +string(3) "bar" +string(3) "bar" +string(3) "bar" +string(3) "foo" |