Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add new signature/parameter matching tests.
- Loading branch information
Showing
3 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,43 @@ | ||
| use v6; | ||
| use Test; | ||
| plan 5; | ||
| plan *; | ||
|
|
||
| #L<S03/Smart matching/Signature-signature> | ||
| { | ||
| ok :(Str) ~~ :(Str), 'signature :(Str) is the same as :(Str)'; | ||
| nok :(Str) ~~ :(Int), 'signature :(Str) is not the same as :(Int)'; | ||
| ok :(Str, Int) ~~ :(Str, Int), 'signature :(Str, Int) is the same as :(Str, Int)'; | ||
| nok :(Str, Int) ~~ :(Int, Str), 'signature :(Str, Int) is not the same as :(Int, Str)'; | ||
| nok :(Str, Int) ~~ :(Str, Int, Str), 'signature :(Str, Int) is not the same as :(Str, Int, Str)'; | ||
| my @tests= | ||
| (:(Int), :(Int), True, | ||
| :(Int, Str), :(Int), False, | ||
| :(Int, Str $?), :(Int), True, | ||
| :(Any), :(Str), True, | ||
| :(*@_), :(Int, Rat, &), True, | ||
| :(:a(:b(:c($x)))), :(:a($x), :b($y)), False, | ||
| :(:a(:b(:c($x)))), :(:a($x)), True, | ||
| :(Any $x ($l, Int $r)), :(Int $x ($y, Str $z)), False, | ||
| :(:x($r) (Str $g, Any $i)), :(:x($t) (Int $f, Any $k)), False, | ||
| :(:x($r) (Str $g, Any $i)), :(:x($t) (Str $f, Str $k)), True, | ||
| :(Int @x, Any $b, Rat $n?, *@_), :(Int @, Str $, Rat, Str), True, | ||
| :(Str $a, Str $b), :(Str $a, Str $b?), False, | ||
| :(Any $x, :$foo!), :(Any $, :$foo), False, | ||
| :(Int, *%_), :(Int, Any :$x!, Str :$y), True, | ||
| :([Any, Str, Numeric]), :(@ (Complex, Str, Int)), True, | ||
| :(Complex $z, :$x, :$y, :$q), :(Complex, *%rest), False, | ||
| :(:$x, Int :$y, Cool :$z, *%_), :(*%_), False, | ||
| :(Mu, Any, Numeric), :(Mu, *@_), False, | ||
| ); | ||
|
|
||
| for @tests -> $s1, $s2, $res { | ||
| is(($s2 ~~ $s1), $res, "{$s2.perl} ~~ {$s1.perl}"); | ||
| } | ||
|
|
||
| #?rakudo skip "Parametric types" | ||
| #?niecza skip "Parametric types" | ||
| # Can't deal with parameters. | ||
| ok (:(::T $x, T $y) R~~ :(Str $y, Str $z)), "Parametric types"; | ||
| #?rakudo skip "Code params with signatures" | ||
| # No support for code params with signatures yet. | ||
| ok (:(&foo(Str --> Bool)) R~~ :(&bar(Str --> Bool))), | ||
| "Code params with signatures"; | ||
| } | ||
|
|
||
| done; | ||
|
|
||
| # vim: ft=perl6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters