summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2008-11-26 19:49:48 +0100
committerSteve Peters <steve@fisharerojo.org>2008-11-26 18:18:44 +0000
commit1c8a42233ec49324eba45ced7d5587186f2e1587 (patch)
tree803de9cc047daf20301bcd44c4ad4d1ea0a02cfc /t
parent412da0037cc4cde2474dfefc6fdc5bdf091f2e24 (diff)
downloadperl-1c8a42233ec49324eba45ced7d5587186f2e1587.tar.gz
Addendum to bug #38809: fix assertion failure, more tests
Message-ID: <492D8C3C.1010003@profvince.com> p4raw-id: //depot/perl@34921
Diffstat (limited to 't')
-rwxr-xr-xt/op/do.t29
1 files changed, 24 insertions, 5 deletions
diff --git a/t/op/do.t b/t/op/do.t
index 90a106cc81..43ce3e8fa9 100755
--- a/t/op/do.t
+++ b/t/op/do.t
@@ -29,7 +29,7 @@ sub ok {
return $ok;
}
-print "1..32\n";
+print "1..38\n";
# Test do &sub and proper @_ handling.
$_[0] = 0;
@@ -105,21 +105,40 @@ $owww = do { 4 if not $zok };
ok( $owww eq '', 'last is if not' );
# [perl #38809]
+@a = (7);
+$x = sub { do { return do { @a } }; 2 }->();
+ok(defined $x && $x == 1, 'return do { } receives caller scalar context');
+@x = sub { do { return do { @a } }; 2 }->();
+ok("@x" eq "7", 'return do { } receives caller list context');
+
@a = (7, 8);
$x = sub { do { return do { 1; @a } }; 3 }->();
-ok(defined $x && $x == 2, 'return do { } receives caller scalar context');
+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');
+ok("@x" eq "7 8", 'return do { ; } receives caller list context');
+
+@b = (11 .. 15);
+$x = sub { do { return do { 1; @a, @b } }; 3 }->();
+ok(defined $x && $x == 5, 'return do { ; , } receives caller scalar context');
+@x = sub { do { return do { 1; @a, @b } }; 3 }->();
+ok("@x" eq "7 8 11 12 13 14 15", 'return do { ; , } receives caller list context');
+
+$x = sub { do { return do { 1; @a }, do { 2; @b } }; 3 }->();
+ok(defined $x && $x == 5, 'return do { ; }, do { ; } receives caller scalar context');
+@x = sub { do { return do { 1; @a }, do { 2; @b } }; 3 }->();
+ok("@x" eq "7 8 11 12 13 14 15", 'return do { ; }, 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');
+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');
+ok("@x" eq "7 8 9 10", 'return do { do { ; } } receives caller list context');
END {
1 while unlink("$$.16", "$$.17", "$$.18");