1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate} 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gaterequire './test.pl'; 9*0Sstevel@tonic-gateplan( tests => 14 ); 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate# test various operations on @_ 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gatesub new1 { bless \@_ } 14*0Sstevel@tonic-gate{ 15*0Sstevel@tonic-gate my $x = new1("x"); 16*0Sstevel@tonic-gate my $y = new1("y"); 17*0Sstevel@tonic-gate is("@$y","y"); 18*0Sstevel@tonic-gate is("@$x","x"); 19*0Sstevel@tonic-gate} 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gatesub new2 { splice @_, 0, 0, "a", "b", "c"; return \@_ } 22*0Sstevel@tonic-gate{ 23*0Sstevel@tonic-gate my $x = new2("x"); 24*0Sstevel@tonic-gate my $y = new2("y"); 25*0Sstevel@tonic-gate is("@$x","a b c x"); 26*0Sstevel@tonic-gate is("@$y","a b c y"); 27*0Sstevel@tonic-gate} 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gatesub new3 { goto &new1 } 30*0Sstevel@tonic-gate{ 31*0Sstevel@tonic-gate my $x = new3("x"); 32*0Sstevel@tonic-gate my $y = new3("y"); 33*0Sstevel@tonic-gate is("@$y","y"); 34*0Sstevel@tonic-gate is("@$x","x"); 35*0Sstevel@tonic-gate} 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gatesub new4 { goto &new2 } 38*0Sstevel@tonic-gate{ 39*0Sstevel@tonic-gate my $x = new4("x"); 40*0Sstevel@tonic-gate my $y = new4("y"); 41*0Sstevel@tonic-gate is("@$x","a b c x"); 42*0Sstevel@tonic-gate is("@$y","a b c y"); 43*0Sstevel@tonic-gate} 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate# see if POPSUB gets to see the right pad across a dounwind() with 46*0Sstevel@tonic-gate# a reified @_ 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gatesub methimpl { 49*0Sstevel@tonic-gate my $refarg = \@_; 50*0Sstevel@tonic-gate die( "got: @_\n" ); 51*0Sstevel@tonic-gate} 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gatesub method { 54*0Sstevel@tonic-gate &methimpl; 55*0Sstevel@tonic-gate} 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gatesub try { 58*0Sstevel@tonic-gate eval { method('foo', 'bar'); }; 59*0Sstevel@tonic-gate print "# $@" if $@; 60*0Sstevel@tonic-gate} 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gatefor (1..5) { try() } 63*0Sstevel@tonic-gatepass(); 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate# bug #21542 local $_[0] causes reify problems and coredumps 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gatesub local1 { local $_[0] } 68*0Sstevel@tonic-gatemy $foo = 'foo'; local1($foo); local1($foo); 69*0Sstevel@tonic-gateprint "got [$foo], expected [foo]\nnot " if $foo ne 'foo'; 70*0Sstevel@tonic-gatepass(); 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gatesub local2 { local $_[0]; last L } 73*0Sstevel@tonic-gateL: { local2 } 74*0Sstevel@tonic-gatepass(); 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate# blead has 9 tests for local(@_) from in t/op/nothr5005.t inserted here 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate# [perl #28032] delete $_[0] was freeing things too early 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate{ 81*0Sstevel@tonic-gate my $flag = 0; 82*0Sstevel@tonic-gate sub X::DESTROY { $flag = 1 } 83*0Sstevel@tonic-gate sub f { 84*0Sstevel@tonic-gate delete $_[0]; 85*0Sstevel@tonic-gate ok(!$flag, 'delete $_[0] : in f'); 86*0Sstevel@tonic-gate } 87*0Sstevel@tonic-gate { 88*0Sstevel@tonic-gate my $x = bless [], 'X'; 89*0Sstevel@tonic-gate f($x); 90*0Sstevel@tonic-gate ok(!$flag, 'delete $_[0] : after f'); 91*0Sstevel@tonic-gate } 92*0Sstevel@tonic-gate ok($flag, 'delete $_[0] : outside block'); 93*0Sstevel@tonic-gate} 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate 96