diff options
author | Vincent Pit <perl@profvince.com> | 2008-09-29 19:36:09 +0200 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2008-11-25 06:28:40 +0000 |
commit | e91684bfbb744fa7e8fdd1131386e3066e5e051b (patch) | |
tree | cd1d9a0d57870802834a2cdbdad6fa6650b79714 /t/op/do.t | |
parent | 74b7c41f0d2d50702adafc135b0d95ee7dd3b77f (diff) | |
download | perl-e91684bfbb744fa7e8fdd1131386e3066e5e051b.tar.gz |
[perl #38809] return do { } : take 3 (or 4...)
Message-ID: <48E0F5E9.4050805@profvince.com>
p4raw-id: //depot/perl@34907
Diffstat (limited to 't/op/do.t')
-rwxr-xr-x | t/op/do.t | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -29,7 +29,7 @@ sub ok { return $ok; } -print "1..26\n"; +print "1..32\n"; # Test do &sub and proper @_ handling. $_[0] = 0; @@ -104,6 +104,23 @@ ok( $owww eq 'swish', 'last is unless' ); $owww = do { 4 if not $zok }; ok( $owww eq '', 'last is if not' ); +# [perl #38809] +@a = (7, 8); +$x = sub { do { return do { 1; @a } }; 3 }->(); +ok(defined $x && $x == 2, 'return do { } receives caller scalar context'); +@x = sub { do { return do { 1; @a } }; 3 }->(); +ok("@x" eq "7 8", 'return do { } receives caller list context'); +@a = (7, 8, 9); +$x = sub { do { do { 1; return @a } }; 4 }->(); +ok(defined $x && $x == 3, 'do { return } receives caller scalar context'); +@x = sub { do { do { 1; return @a } }; 4 }->(); +ok("@x" eq "7 8 9", 'do { return } receives caller list context'); +@a = (7, 8, 9, 10); +$x = sub { do { return do { 1; do { 2; @a } } }; 5 }->(); +ok(defined $x && $x == 4, 'return do { do { } } receives caller scalar context'); +@x = sub { do { return do { 1; do { 2; @a } } }; 5 }->(); +ok("@x" eq "7 8 9 10", 'return do { do { } } receives caller list context'); + END { 1 while unlink("$$.16", "$$.17", "$$.18"); } |