factor out Filter::Keyword::Parser
[p5sagit/Filter-Keyword.git] / t / simple.t
CommitLineData
3b08744b 1use strictures 1;
2use Test::More qw(no_plan);
3use Filter::Keyword;
4
5BEGIN {
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
24method main { 'YAY '.$self };
25
26my $x = "method foo bar baz";
27
28method spoon { 'I HAZ A SPOON'};
29
30warn __PACKAGE__->main;
31warn __PACKAGE__->spoon;