diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-11 23:03:39 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-11 23:03:39 +0000 |
commit | 3c1f3fdf5f9ede82336e0651b455c2fc686ec1c7 (patch) | |
tree | b162531ab600b6815424c20aa89981469fca5f02 /t | |
parent | 7f61b687036bb8a098a2e70b387919a448b7bd62 (diff) | |
download | perl-3c1f3fdf5f9ede82336e0651b455c2fc686ec1c7.tar.gz |
fix closures in optimized C<for (1..5)> (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
Diffstat (limited to 't')
-rwxr-xr-x | t/op/closure.t | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/t/op/closure.t b/t/op/closure.t index 1220998b6b..95d44f51e3 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 <rootbeer@teleport.com>. { @@ -452,3 +479,4 @@ END } # End of foreach $inner_type } + |