my
$name
=
'filter_example'
;
BEGIN {
plan
tests
=> 1;
}
my
$source
=
<<'ENDS';
use Method::Signatures::Simple;
method foo1 { $self->bar }
# with signature
method foo2($bar, %opts) { $self->bar(reverse $bar) if $opts{rev};
}
# attributes
method foo3 : lvalue { $self->{foo}
}
# change invocant name
method
foo4 ( $class : $bar ) { $class->bar($bar) }
ENDS
my
$expect
=
<<'ENDE';
use Method::Signatures::Simple;
method foo1 { $self->bar }
# with signature
method foo2 ( $bar, %opts ) {
$self->bar( reverse $bar ) if $opts{rev};
}
# attributes
method foo3 : lvalue {
$self->{foo};
}
# change invocant name
method foo4 ( $class : $bar ) { $class->bar($bar) }
ENDE
my
$output
;
my
$stderr_string
;
my
$errorfile_string
;
my
$params
=
"-ssp=2"
;
my
$err
= Perl::Tidy::perltidy(
argv
=>
''
,
perltidyrc
=> \
$params
,
prefilter
=>
sub
{
$_
=
$_
[0]; s/^\s
*method
\s+(\w.*)/
sub
METHOD_$1/gm;
return
$_
},
postfilter
=>
sub
{
$_
=
$_
[0]; s/
sub
\s+METHOD_/method /gm;
return
$_
},
source
=> \
$source
,
destination
=> \
$output
,
stderr
=> \
$stderr_string
,
errorfile
=> \
$errorfile_string
,
);
if
(
$err
||
$stderr_string
||
$errorfile_string
) {
ok(0);
}
else
{
is(
$output
,
$expect
,
$name
);
}