7 local $Data::Dumper::Useqq = 1;
8 local $Data::Dumper::Terse = 1;
9 my $out = Data::Dumper::Dumper($_[0]);
15 (our $Kw = Filter::Keyword->new(
16 target_package => __PACKAGE__,
17 keyword_name => 'method',
20 if (my ($stripped, $matches) = $kw->match_source('', '{')) {
21 my $name = $kw->current_match->[0];
22 $stripped =~ s/{/; sub ${name} { my \$self = shift;/;
23 return ($stripped, 1);
30 (our $Kw2 = Filter::Keyword->new(
31 target_package => __PACKAGE__,
32 keyword_name => 'function',
35 if (my ($stripped, $matches) = $kw->match_source('', '{')) {
36 my $name = $kw->current_match->[0];
37 $stripped =~ s/{/; sub ${name} {/;
38 return ($stripped, 1);
47 method yay { is(__LINE__, 38, 'line number correct inside method' ); "YAY $self" } is(__LINE__, 38, 'line number correct on same line after method');
49 is(__LINE__, 40, 'line number correct after first method');
51 my $x = "method foo bar baz";
53 is(__PACKAGE__->yay, 'YAY ' . __PACKAGE__, 'result of method correct');
56 is(__LINE__, 47, 'line number correct in multiline method');
60 is(__PACKAGE__->spoon, 'I HAZ A SPOON', 'result of second method correct');
62 function fun { is(__LINE__, 53, 'line number in function correct'); 'OH WHAT FUN' }
64 is(__PACKAGE__->fun, 'OH WHAT FUN', 'result of function correct');
66 is(__LINE__, 57, 'line number after function correct');