From: Gurusamy Sarathy Date: Sat, 11 Jul 1998 23:03:39 +0000 (+0000) Subject: fix closures in optimized C (only the tests are in this X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c1f3fdf5f9ede82336e0651b455c2fc686ec1c7;p=p5sagit%2Fp5-mst-13.2.git fix closures in optimized C (only the tests are in this change, the pp_hot.c fix accidentally went in change#1441) p4raw-link: @1441 on //depot/perl: 7f61b687036bb8a098a2e70b387919a448b7bd62 p4raw-id: //depot/perl@1442 --- diff --git a/t/op/closure.t b/t/op/closure.t index 1220998..95d44f5 100755 --- a/t/op/closure.t +++ b/t/op/closure.t @@ -12,7 +12,7 @@ BEGIN { use Config; -print "1..167\n"; +print "1..169\n"; my $test = 1; sub test (&) { @@ -130,6 +130,33 @@ test { &{$foo[4]}() == 0 }; +# test if closures get created in optimized for loops + +my %foo; +for my $n ('A'..'E') { + $foo{$n} = sub { $n eq $_[0] }; +} + +test { + &{$foo{A}}('A') and + &{$foo{B}}('B') and + &{$foo{C}}('C') and + &{$foo{D}}('D') and + &{$foo{E}}('E') +}; + +for my $n (0..4) { + $foo[$n] = sub { $n == $_[0] }; +} + +test { + &{$foo[0]}(0) and + &{$foo[1]}(1) and + &{$foo[2]}(2) and + &{$foo[3]}(3) and + &{$foo[4]}(4) +}; + # Additional tests by Tom Phoenix . { @@ -452,3 +479,4 @@ END } # End of foreach $inner_type } +