blob: 06db9143132b8fe319a8f485b844a3a834060b14 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
BEGIN {
package My::Parser;
use Exporter 'import';
our @EXPORT = ('foo', 'bar');
use Parse::Keyword {
foo => \&parse_foo,
bar => \&parse_bar,
};
sub foo {}
sub parse_foo {
lex_read_space;
die unless lex_peek eq '{';
parse_block(1)->();
return (sub {}, 1);
}
sub bar { $::body = $_[0] }
sub parse_bar {
lex_read_space;
die unless lex_peek eq '{';
my $body = parse_block;
return (sub { $body }, 1);
}
$INC{'My/Parser.pm'} = __FILE__;
}
use My::Parser;
my $bar;
my $baz = 5;
foo {
bar { $baz }
}
is($::body->(), 5);
done_testing;
|