10 BEGIN { $::EVALED{'one'} = 1 }
14 my $two = quote_sub q{
15 BEGIN { $::EVALED{'two'} = 1 }
17 } => { '$x' => \do { my $x = 0 } };
19 ok(!keys %EVALED, 'Nothing evaled yet');
21 my $u_one = unquote_sub $one;
24 [ sort keys %EVALED ], [ qw(one) ],
28 is($one->(), 42, 'One (quoted version)');
30 is($u_one->(), 42, 'One (unquoted version)');
32 is($two->(), 3, 'Two (quoted version)');
33 is(unquote_sub($two)->(), 4, 'Two (unquoted version)');
34 is($two->(), 5, 'Two (quoted version again)');
36 my $three = quote_sub 'Foo::three' => q{
38 die +(caller(0))[3] if @_ > 2;
40 } => { '$x' => \do { my $x = 'spoon' } };
42 is(Foo->three, 'spoon', 'get ok (named method)');
43 is(Foo->three('fork'), 'fork', 'set ok (named method)');
44 is(Foo->three, 'fork', 're-get ok (named method)');
46 exception { Foo->three(qw(full cutlery set)) }, qr/Foo::three/,
47 'exception contains correct name'