Skip to content

Commit a264deb

Browse files
committed
Add test for exceptions.
1 parent 8cf43d8 commit a264deb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
A pipe interrupted by an exception, to demonstrate correct order of execution.
3+
--FILE--
4+
<?php
5+
6+
function foo() { echo __FUNCTION__, PHP_EOL; return 1; }
7+
function bar() { echo __FUNCTION__, PHP_EOL; return false; }
8+
function baz($in) { echo __FUNCTION__, PHP_EOL; return $in; }
9+
function quux($in) { echo __FUNCTION__, PHP_EOL; throw new \Exception('Oops'); } // This is line 6.
10+
11+
try {
12+
$result = foo()
13+
|> (bar() ? baz(...) : quux(...))
14+
|> var_dump(...);
15+
}
16+
catch (Throwable $e) {
17+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
18+
}
19+
20+
try {
21+
$result = foo()
22+
|> (throw new Exception('Break'))
23+
|> (bar() ? baz(...) : quux(...))
24+
|> var_dump(...);
25+
}
26+
catch (Throwable $e) {
27+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
28+
}
29+
30+
?>
31+
--EXPECTF--
32+
foo
33+
bar
34+
quux
35+
Exception: Oops
36+
foo
37+
Exception: Break

0 commit comments

Comments
 (0)