]> granicus.if.org Git - php/commitdiff
Added test for bug #69160 (current behavior is correct)
authorBob Weinand <bobwei9@hotmail.com>
Sat, 7 Mar 2015 19:59:42 +0000 (20:59 +0100)
committerBob Weinand <bobwei9@hotmail.com>
Sat, 7 Mar 2015 19:59:42 +0000 (20:59 +0100)
Zend/tests/generators/yield_unary_precedence.phpt [new file with mode: 0644]

diff --git a/Zend/tests/generators/yield_unary_precedence.phpt b/Zend/tests/generators/yield_unary_precedence.phpt
new file mode 100644 (file)
index 0000000..9357168
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+When + or - are used on yield, they must be unary (and not binary) (Bug #69160)
+--FILE--
+<?php
+function gen() {
+       var_dump(yield +1);
+       var_dump(yield -1);
+       var_dump(yield * -1); // other ops still should behave normally
+}
+
+for ($gen = gen(); $gen->valid(); $gen->send(1)) {
+       echo "\n";
+       var_dump($gen->current());
+}
+?>
+--EXPECT--
+
+int(1)
+int(1)
+
+int(-1)
+int(1)
+
+NULL
+int(-1)
+