summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/t/op/closure.t
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/t/op/closure.t')
-rwxr-xr-xcontrib/perl5/t/op/closure.t29
1 files changed, 27 insertions, 2 deletions
diff --git a/contrib/perl5/t/op/closure.t b/contrib/perl5/t/op/closure.t
index 95d44f5..c691d6f 100755
--- a/contrib/perl5/t/op/closure.t
+++ b/contrib/perl5/t/op/closure.t
@@ -7,12 +7,12 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
use Config;
-print "1..169\n";
+print "1..171\n";
my $test = 1;
sub test (&) {
@@ -157,6 +157,31 @@ test {
&{$foo[4]}(4)
};
+for my $n (0..4) {
+ $foo[$n] = sub {
+ # no intervening reference to $n here
+ sub { $n == $_[0] }
+ };
+}
+
+test {
+ $foo[0]->()->(0) and
+ $foo[1]->()->(1) and
+ $foo[2]->()->(2) and
+ $foo[3]->()->(3) and
+ $foo[4]->()->(4)
+};
+
+{
+ my $w;
+ $w = sub {
+ my ($i) = @_;
+ test { $i == 10 };
+ sub { $w };
+ };
+ $w->(10);
+}
+
# Additional tests by Tom Phoenix <rootbeer@teleport.com>.
{
OpenPOWER on IntegriCloud