1 # Test use of prefilter and postfilter parameters
11 my $source = <<'ENDS';
12 use Method::Signatures::Simple;
14 method foo1 { $self->bar }
17 method foo2($bar, %opts) { $self->bar(reverse $bar) if $opts{rev};
21 method foo3 : lvalue { $self->{foo}
24 # change invocant name
26 foo4 ($class: $bar) { $class->bar($bar) }
29 my $expect = <<'ENDE';
30 use Method::Signatures::Simple;
31 method foo1 { $self->bar }
34 method foo2 ( $bar, %opts ) {
35 $self->bar( reverse $bar ) if $opts{rev};
39 method foo3 : lvalue {
43 # change invocant name
44 method foo4 ($class: $bar) { $class->bar($bar) }
50 my $err = Perl::Tidy::perltidy(
51 argv => '-npro', # fix for RT#127679, avoid reading unwanted .perltidyrc
53 sub { $_ = $_[0]; s/^\s*method\s+(\w.*)/sub METHOD_$1/gm; return $_ },
54 postfilter => sub { $_ = $_[0]; s/sub\s+METHOD_/method /gm; return $_ },
56 destination => \$output,
57 stderr => \$stderr_string,
58 errorfile => \$errorfile_string, # not used when -se flag is set
60 if ( $err || $stderr_string || $errorfile_string ) {
64 ok( $output, $expect );