8 use Test::Requires 'PadWalker';
12 my $env = { '$foo' => \$foo };
14 my $code = eval_closure(
15 source => 'sub { push @$foo, @_ }',
18 is_deeply(scalar(PadWalker::closed_over($code)), $env,
19 "closed over the right things");
25 my $env = { '$foo' => \$bar, '$bar' => \$foo };
27 my $code = eval_closure(
28 source => 'sub { push @$foo, @_; $bar->{foo} = \@_ }',
31 is_deeply(scalar(PadWalker::closed_over($code)), $env,
32 "closed over the right things");
36 local $TODO = "we still have to close over \$__captures";
38 my $env = { '$foo' => \$foo };
40 my $code = eval_closure(
41 source => 'sub { push @$foo, @_; return $__captures }',
44 is_deeply(scalar(PadWalker::closed_over($code)), $env,
45 "closed over the right things");
48 # it'd be nice if we could test that closing over other things wasn't possible,
49 # but perl's optimizer gets in the way of that