Filter-signatures

 view release on metacpan or  search on metacpan

t/03-compilation-output.t  view on Meta::CPAN

}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Default arguments with parentheses and values work";
sub  { my ($self,$cb)=@_;$cb = sub { } if @_ <= 1;();

}
RESULT

$_ = <<'SUB';
sub f ($a,@) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Slurpy discard argument works";
sub f { my ($a,undef)=@_;();
...
}
RESULT

t/03-compilation-output.t  view on Meta::CPAN

}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Default arguments that look like comments";
my @args;
sub  { my ($self,$foo)=@_;$foo = $#args if @_ <= 1;();
}
RESULT

$_ = <<'SUB';
sub f ($a = /\w/ ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Argument lists containing regular expressions work";
sub f { my ($a)=@_;$a = /\w/ if @_ <= 0;();
...
}
RESULT

$_ = <<'SUB';
sub f ($a = \$b, $c=\@d, $e=\%f, $g=\&h, $i=\*j ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Argument lists containing scalar references";
sub f { my ($a,$c,$e,$g,$i)=@_;$a = \$b if @_ <= 0;$c = \@d if @_ <= 1;$e = \%f if @_ <= 2;$g = \&h if @_ <= 3;$i = \*j if @_ <= 4;();
...
}
RESULT

$_ = <<'SUB';
sub f ($a = /\(/ ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Argument lists containing unmatched parentheses work";
sub f { my ($a)=@_;$a = /\(/ if @_ <= 0;();
...
}
RESULT

$_ = <<'SUB';
sub f ($a = /[\(]/ ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Characterclasses with unmatched quoted parentheses work";
sub f { my ($a)=@_;$a = /[\(]/ if @_ <= 0;();
...
}
RESULT

{ local $TODO = "Recursive parentheses don't work on $]"
  if( $] < 5.010 );

$_ = <<'SUB';
sub f ($a = /[\)]/ ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Characterclasses with unmatched quoted parentheses work";
sub f { my ($a)=@_;$a = /[\)]/ if @_ <= 0;();
...
}
RESULT
}

{ local $TODO = 'More robust regexp parsing needed';
$_ = <<'SUB';
sub f ($a = /[(]/ ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Regular expressions containing characterclasses with unmatched parentheses work";
sub f { my ($a)=@_;$a = /\(/ if @_ <= 0;();
...
}
RESULT

$_ = <<'SUB';
sub f ($a = /[)]/ ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Regular expressions containing characterclasses with unmatched parentheses work";
sub f { my ($a)=@_;$a = /[)]/ if @_ <= 0;();
...
}
RESULT

}

{ local $TODO = "Recursive parentheses don't work on $]"
  if( $] < 5.010 );

$_ = <<'SUB';
sub f ($a = qr(\() ) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Argument lists containing unmatched parentheses within qr-strings work";
sub f { my ($a)=@_;$a = qr(\() if @_ <= 0;();
...
}
RESULT
}

$_ = <<'SUB';
sub f ($a = do { }) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "do-blocks work";
sub f { my ($a)=@_;$a = do { } if @_ <= 0;();
...
}
RESULT

{ local $TODO = "Recursive parentheses don't work on $]"
  if( $] < 5.010 );

$_ = <<'SUB';
sub f ($a = substr("abc",0,1)) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Commas within subroutine calls don't split the argument lists";
sub f { my ($a)=@_;$a = substr("abc",0,1) if @_ <= 0;();
...
}
RESULT
}

$_ = <<'SUB';
sub f ($a = /\,/, $b=1) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Commas within regular expression matches don't split the argument lists";
sub f { my ($a,$b)=@_;$a = /\,/ if @_ <= 0;$b = 1 if @_ <= 1;();
...
}
RESULT

$_ = <<'SUB';
sub f ($a = /\,/, $b=1) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Commas within regular expression matches don't split the argument lists";
sub f { my ($a,$b)=@_;$a = /\,/ if @_ <= 0;$b = 1 if @_ <= 1;();
...
}
RESULT

$_ = <<'SUB';
sub f ($a = do { $x = "abc"; return substr $x,0,1}) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Commas within do-blocks don't split the argument lists";
sub f { my ($a)=@_;$a = do { $x = "abc"; return substr $x,0,1} if @_ <= 0;();
...
}
RESULT

{ local $TODO = "Recursive parentheses don't work on $]"
  if( $] < 5.010 );

$_ = <<'SUB';
sub f ($a = do { $x = "abc"; return substr($x,0,1)}) {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "do-blocks with parentheses work";
sub f { my ($a)=@_;$a = do { $x = "abc"; return substr($x,0,1)} if @_ <= 0;();
...
}
RESULT
}

# This is a test for the placeholders that Filter::Simple supplies - if you
# have enough of them, "interesting" characters pop up within these placeholders
# We have an interesting dependency on the format of these placeholders.
$_ = <<'SUB';
sub f ($a = "...(") {
...
}
SUB
Filter::signatures::transform_arguments();
is $_, <<'RESULT', "Parentheses in (replaced) string arguments work";
sub f { my ($a)=@_;$a = "...(" if @_ <= 0;();
...
}
RESULT



( run in 1.965 second using v1.01-cache-2.11-cpan-9169edd2b0e )