1 # Test use of prefilter and postfilter parameters
6 my $name = 'filter_example';
12 my $source = <<'ENDS';
13 use Method::Signatures::Simple;
15 method foo1 { $self->bar }
18 method foo2($bar, %opts) { $self->bar(reverse $bar) if $opts{rev};
22 method foo3 : lvalue { $self->{foo}
25 # change invocant name
27 foo4 ( $class : $bar ) { $class->bar($bar) }
30 my $expect = <<'ENDE';
31 use Method::Signatures::Simple;
32 method foo1 { $self->bar }
35 method foo2 ( $bar, %opts ) {
36 $self->bar( reverse $bar ) if $opts{rev};
40 method foo3 : lvalue {
44 # change invocant name
45 method foo4 ( $class : $bar ) { $class->bar($bar) }
52 my $err = Perl::Tidy::perltidy(
54 #argv => '-npro', # fix for RT#127679, avoid reading unwanted .perltidyrc
56 perltidyrc => \$params, # avoid reading unwanted .perltidyrc
58 sub { $_ = $_[0]; s/^\s*method\s+(\w.*)/sub METHOD_$1/gm; return $_ },
59 postfilter => sub { $_ = $_[0]; s/sub\s+METHOD_/method /gm; return $_ },
61 destination => \$output,
62 stderr => \$stderr_string,
63 errorfile => \$errorfile_string, # not used when -se flag is set
65 if ( $err || $stderr_string || $errorfile_string ) {
69 is( $output, $expect, $name );