From ec39802e4e7dac14b629f41017d04573a6a5fdc4 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Tue, 23 Sep 2014 16:28:02 +0100 Subject: [PATCH] Extended coalesce operator test case for ordering/short-circuiting --- tests/lang/operators/coalesce.phpt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/lang/operators/coalesce.phpt b/tests/lang/operators/coalesce.phpt index 327a11a432..2ee54c5276 100644 --- a/tests/lang/operators/coalesce.phpt +++ b/tests/lang/operators/coalesce.phpt @@ -42,6 +42,14 @@ var_dump($arr["bing"][0] ?? 3); var_dump($arr["bing"][1] ?? 3); echo PHP_EOL; var_dump(foobar()[0] ?? false); +echo PHP_EOL; +function f($x) +{ + printf("%s(%d)\n", __FUNCTION__, $x); + return $x; +} + +$a = f(null) ?? f(1) ?? f(2); ?> --EXPECTF-- int(3) @@ -65,4 +73,7 @@ string(4) "bang" int(3) called -string(1) "a" \ No newline at end of file +string(1) "a" + +f(0) +f(1) \ No newline at end of file -- 2.40.0