diff options
author | Nikita Popov <nikic@php.net> | 2014-12-07 22:58:14 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2014-12-07 23:00:48 +0100 |
commit | c6d0c55a23918c8a5e8e2f583fc9ce58ddcd4e54 (patch) | |
tree | de6e4ba551f2bab20ffbeef532b02a8805adc521 /Zend/tests | |
parent | aa52fcf179d9e233075e4d213d5708cc5b5e1ae2 (diff) | |
download | php-git-c6d0c55a23918c8a5e8e2f583fc9ce58ddcd4e54.tar.gz |
Fix arrow operator precedence
I accidentially added => as the highest-precedence operator...
Diffstat (limited to 'Zend/tests')
-rw-r--r-- | Zend/tests/generators/yield_precedence.phpt | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Zend/tests/generators/yield_precedence.phpt b/Zend/tests/generators/yield_precedence.phpt new file mode 100644 index 0000000000..6b87fa0364 --- /dev/null +++ b/Zend/tests/generators/yield_precedence.phpt @@ -0,0 +1,51 @@ +--TEST-- +Precedence of yield and arrow operators +--FILE-- +<?php + +function gen() { + yield "a" . "b"; + yield "a" or die; + yield "k" => "a" . "b"; + yield "k" => "a" or die; + var_dump([yield "k" => "a" . "b"]); + yield yield "k1" => yield "k2" => "a" . "b"; + yield yield "k1" => (yield "k2") => "a" . "b"; + var_dump([yield "k1" => yield "k2" => "a" . "b"]); + var_dump([yield "k1" => (yield "k2") => "a" . "b"]); +} + +$g = gen(); +for ($g->rewind(), $i = 1; $g->valid(); $g->send($i), $i++) { + echo "{$g->key()} => {$g->current()}\n"; +} + +?> +--EXPECT-- +0 => ab +1 => a +k => ab +k => a +k => ab +array(1) { + [0]=> + int(5) +} +k2 => ab +k1 => 6 +2 => 7 +3 => k2 +k1 => 9 +10 => ab +k2 => ab +k1 => 12 +array(1) { + [0]=> + int(13) +} +11 => k2 +k1 => 14 +array(1) { + [15]=> + string(2) "ab" +} |