Commit | Line | Data |
3b08744b |
1 | use strictures 1; |
2 | use Test::More qw(no_plan); |
3 | use Filter::Keyword; |
4 | |
5 | BEGIN { |
6 | (our $Kw = Filter::Keyword->new( |
c46d1069 |
7 | parser => { |
8 | target_package => __PACKAGE__, |
9 | keyword_name => 'method', |
10 | parser => sub { |
11 | my $obj = shift; |
12 | if (my ($stripped, $matches) = $obj->match_source('', '{')) { |
13 | my $name = $obj->current_match->[0]; |
14 | $stripped =~ s/{/; sub ${name} { my \$self = shift;/; |
15 | return ($stripped, 1); |
16 | } else { |
17 | return ('', 1); |
18 | } |
19 | } |
20 | }, |
21 | ))->install; |
3b08744b |
22 | } |
23 | |
24 | method main { 'YAY '.$self }; |
25 | |
26 | my $x = "method foo bar baz"; |
27 | |
28 | method spoon { 'I HAZ A SPOON'}; |
29 | |
30 | warn __PACKAGE__->main; |
31 | warn __PACKAGE__->spoon; |