blob: 8171972cd7b249d5ce2feb1b65b2322da00a25cb (
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
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
{
package Foo;
use Parse::Keyword { bar => \&bar_parser };
sub bar { @_ }
sub bar_parser {
return sub { return (1, 2, 3) }
}
::is_deeply([bar], [1, 2, 3]);
}
{
package Bar;
use Parse::Keyword { baz => \&baz_parser };
my $code;
sub baz { $code = $_[0] }
sub baz_parser {
lex_read_space;
my $block = parse_block;
return (sub { $block }, 1);
}
baz {
my $foo = 1;
return $foo + 2;
}
::is(ref($code), 'CODE');
::is($code->(), 3);
}
done_testing;
|