X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fdo.t;h=e47441a8cc515bc91e8190486f65824fd51c2fe1;hb=6ec5370cb0aeb185d92b8fd2bad21bb10f75b30e;hp=dd378cfe7ac07008c22f84e00a601fb1149747d0;hpb=dd3e51dc8ab0e4da0f911ca693aa0ceaaf79318a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/do.t b/t/op/do.t index dd378cf..e47441a 100644 --- 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"); }