diff options
author | James E Keenan <jkeenan@cpan.org> | 2014-09-13 08:51:48 -0400 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2015-01-13 08:19:32 +0000 |
commit | 0720669403e73c1998db09917a7304300a6354cb (patch) | |
tree | deaf1e528987331114451fbbce55e7f106874ef5 /t/op | |
parent | 5ebde54265c6b44c115c22179dd2e28ef5eaa85c (diff) | |
download | perl-0720669403e73c1998db09917a7304300a6354cb.tar.gz |
Semicolon before ellipsis inside block disambiguates.
Correct documentation which indicated that, inside a block, a semicolon after
an ellipsis statement would disambiguate between a block and a hash reference
constructor. The semicolon must precede the ellipsis to perform this
disambiguation.
Add tests to demonstrate that whitespace around the ellipsis statement does
not impeded the disambiguation. Add perldelta entry.
For: RT #122661
(cherry picked from commit 12d22d1fe17e8471834a01cd417792ac5c022d62)
Diffstat (limited to 't/op')
-rw-r--r-- | t/op/yadayada.t | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/t/op/yadayada.t b/t/op/yadayada.t index 770a51ea90..a213bec2be 100644 --- a/t/op/yadayada.t +++ b/t/op/yadayada.t @@ -8,14 +8,39 @@ BEGIN { use strict; -plan 5; +plan 9; -my $err = "Unimplemented at $0 line " . ( __LINE__ + 2 ) . ".\n"; +my $err; +my $err1 = "Unimplemented at $0 line "; +my $err2 = ".\n"; +$err = $err1 . ( __LINE__ + 1 ) . $err2; eval { ... }; +is $@, $err, "Execution of ellipsis statement reported 'Unimplemented' code"; +$@ = ''; -is $@, $err; +note("RT #122661: Semicolon before ellipsis statement disambiguates to indicate block rather than hash reference"); +my @input = (3..5); +my @transformed; +$err = $err1 . ( __LINE__ + 1 ) . $err2; +eval { @transformed = map {; ... } @input; }; +is $@, $err, "Disambiguation case 1"; +$@ = ''; +$err = $err1 . ( __LINE__ + 1 ) . $err2; +eval { @transformed = map {;...} @input; }; +is $@, $err, "Disambiguation case 2"; +$@ = ''; + +$err = $err1 . ( __LINE__ + 1 ) . $err2; +eval { @transformed = map {; ...} @input; }; +is $@, $err, "Disambiguation case 3"; +$@ = ''; + +$err = $err1 . ( __LINE__ + 1 ) . $err2; +eval { @transformed = map {;... } @input; }; +is $@, $err, "Disambiguation case 4"; +$@ = ''; # # Regression tests, making sure ... is still parsable as an operator. |