Explicitly check that our $_; is special, and forced to main::
[p5sagit/p5-mst-13.2.git] / t / op / do.t
index dd378cf..e47441a 100644 (file)
--- a/t/op/do.t
+++ b/t/op/do.t
@@ -29,17 +29,23 @@ sub ok {
     return $ok;
 }
 
-print "1..44\n";
+print "1..50\n";
 
 # Test do &sub and proper @_ handling.
 $_[0] = 0;
-$result = do foo1(1);
+{
+    no warnings 'deprecated';
+    $result = do foo1(1);
+}
 
 ok( $result eq 'value',  ":$result: eq :value:" );
 ok( $_[0] == 0 );
 
 $_[0] = 0;
-$result = do foo2(0,1,0);
+{
+    no warnings 'deprecated';
+    $result = do foo2(0,1,0);
+}
 ok( $result eq 'value', ":$result: eq :value:" );
 ok( $_[0] == 0 );
 
@@ -50,10 +56,16 @@ sub blather {
     ok 1 foreach @_;
 }
 
-do blather("ayep","sho nuff");
+{
+    no warnings 'deprecated';
+    do blather("ayep","sho nuff");
+}
 @x = ("jeepers", "okydoke");
 @y = ("uhhuh", "yeppers");
-do blather(@x,"noofie",@y);
+{
+    no warnings 'deprecated';
+    do blather(@x,"noofie",@y);
+}
 
 unshift @INC, '.';
 
@@ -160,6 +172,25 @@ ok($x == 4, 'if (1) { ...; @a } receives caller scalar context');
 @x = sub { if (1) { 0; @a } }->();
 ok("@x" eq "24 25 26 27", 'if (1) { ...; @a } receives caller list context');
 
+$x = sub { if (1) { 0; 20 } else{} }->();
+ok($x == 20, 'if (1) { ...; $x } else{} receives caller scalar context');
+
+@a = (24 .. 27);
+$x = sub { if (1) { 0; @a } else{} }->();
+ok($x == 4, 'if (1) { ...; @a } else{} receives caller scalar context');
+@x = sub { if (1) { 0; @a } else{} }->();
+ok("@x" eq "24 25 26 27", 'if (1) { ...; @a } else{} receives caller list context');
+
+$x = sub { if (0){} else { 0; 20 } }->();
+ok($x == 20, 'if (0){} else { ...; $x } receives caller scalar context');
+
+@a = (24 .. 27);
+$x = sub { if (0){} else { 0; @a } }->();
+ok($x == 4, 'if (0){} else { ...; @a } receives caller scalar context');
+@x = sub { if (0){} else { 0; @a } }->();
+ok("@x" eq "24 25 26 27", 'if (0){} else { ...; @a } receives caller list context');
+
+
 END {
     1 while unlink("$$.16", "$$.17", "$$.18");
 }