1*898184e3Ssthenuse warnings; 2*898184e3Ssthenuse strict; 3*898184e3Ssthen 4*898184e3Ssthenuse Test::More tests => 76; 5*898184e3Ssthen 6*898184e3Ssthenuse XS::APItest qw(pad_scalar); 7*898184e3Ssthen 8*898184e3Ssthenis pad_scalar(1, "foo"), "NOT_IN_PAD"; 9*898184e3Ssthenis pad_scalar(2, "foo"), "NOT_IN_PAD"; 10*898184e3Ssthenis pad_scalar(3, "foo"), "NOT_IN_PAD"; 11*898184e3Ssthenis pad_scalar(4, "foo"), "NOT_IN_PAD"; 12*898184e3Ssthenis pad_scalar(1, "bar"), "NOT_IN_PAD"; 13*898184e3Ssthenis pad_scalar(2, "bar"), "NOT_IN_PAD"; 14*898184e3Ssthenis pad_scalar(3, "bar"), "NOT_IN_PAD"; 15*898184e3Ssthen 16*898184e3Ssthenour $foo = "wibble"; 17*898184e3Ssthenmy $bar = "wobble"; 18*898184e3Ssthenis pad_scalar(1, "foo"), "NOT_MY"; 19*898184e3Ssthenis pad_scalar(2, "foo"), "NOT_MY"; 20*898184e3Ssthenis pad_scalar(3, "foo"), "NOT_MY"; 21*898184e3Ssthenis pad_scalar(4, "foo"), "NOT_MY"; 22*898184e3Ssthenis pad_scalar(1, "bar"), "wobble"; 23*898184e3Ssthenis pad_scalar(2, "bar"), "wobble"; 24*898184e3Ssthenis pad_scalar(3, "bar"), "wobble"; 25*898184e3Ssthen 26*898184e3Ssthensub aa($); 27*898184e3Ssthensub aa($) { 28*898184e3Ssthen my $xyz; 29*898184e3Ssthen ok \pad_scalar(1, "xyz") == \$xyz; 30*898184e3Ssthen ok \pad_scalar(2, "xyz") == \$xyz; 31*898184e3Ssthen ok \pad_scalar(3, "xyz") == \$xyz; 32*898184e3Ssthen aa(0) if $_[0]; 33*898184e3Ssthen ok \pad_scalar(1, "xyz") == \$xyz; 34*898184e3Ssthen ok \pad_scalar(2, "xyz") == \$xyz; 35*898184e3Ssthen ok \pad_scalar(3, "xyz") == \$xyz; 36*898184e3Ssthen is pad_scalar(1, "bar"), "wobble"; 37*898184e3Ssthen is pad_scalar(2, "bar"), "wobble"; 38*898184e3Ssthen is pad_scalar(3, "bar"), "wobble"; 39*898184e3Ssthen} 40*898184e3Ssthenaa(1); 41*898184e3Ssthen 42*898184e3Ssthensub bb() { 43*898184e3Ssthen my $counter = 0; 44*898184e3Ssthen my $foo = \$counter; 45*898184e3Ssthen return sub { 46*898184e3Ssthen ok pad_scalar(1, "foo") == \pad_scalar(1, "counter"); 47*898184e3Ssthen ok pad_scalar(2, "foo") == \pad_scalar(1, "counter"); 48*898184e3Ssthen ok pad_scalar(3, "foo") == \pad_scalar(1, "counter"); 49*898184e3Ssthen ok pad_scalar(4, "foo") == \pad_scalar(1, "counter"); 50*898184e3Ssthen if(pad_scalar(1, "counter") % 3 == 0) { 51*898184e3Ssthen return pad_scalar(1, "counter")++; 52*898184e3Ssthen } elsif(pad_scalar(1, "counter") % 3 == 0) { 53*898184e3Ssthen return pad_scalar(2, "counter")++; 54*898184e3Ssthen } else { 55*898184e3Ssthen return pad_scalar(3, "counter")++; 56*898184e3Ssthen } 57*898184e3Ssthen }; 58*898184e3Ssthen} 59*898184e3Ssthenmy $a = bb(); 60*898184e3Ssthenmy $b = bb(); 61*898184e3Ssthenis $a->(), 0; 62*898184e3Ssthenis $a->(), 1; 63*898184e3Ssthenis $a->(), 2; 64*898184e3Ssthenis $a->(), 3; 65*898184e3Ssthenis $b->(), 0; 66*898184e3Ssthenis $b->(), 1; 67*898184e3Ssthenis $a->(), 4; 68*898184e3Ssthenis $b->(), 2; 69*898184e3Ssthen 70*898184e3Ssthenis pad_scalar(1, "foo"), "NOT_MY"; 71*898184e3Ssthenis pad_scalar(2, "foo"), "NOT_MY"; 72*898184e3Ssthenis pad_scalar(3, "foo"), "NOT_MY"; 73*898184e3Ssthenis pad_scalar(4, "foo"), "NOT_MY"; 74*898184e3Ssthen 75*898184e3Ssthen1; 76