Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
equiv/tighter/looser with is equiv<+> syntax
rakudo patch forthcoming
  • Loading branch information
cognominal committed Oct 17, 2015
1 parent b38cc69 commit ad5e410
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions S06-traits/precedence.t
Expand Up @@ -10,7 +10,7 @@ Tests for precedence of self defined operators

# L<S06/Subroutine traits/"relative to an existing">

plan 10;
plan 15;

do {
sub prefix:<!> (Int $x) is tighter(&infix:<**>) {
Expand Down Expand Up @@ -43,18 +43,46 @@ do {
return $a * $b;
}

is 2 mul 3 + 4, 14, "'is looser' infix works 1";
is 4 + 3 mul 2 , 14, "'is looser' infix works 2";
is 2 mul 3 + 4, 14, "'is looser(&infix:<+>' works 1";
is 4 + 3 mul 2 , 14, "'is looser(&infix:<+>' works 2";
}

{
sub infix:<mul> ($a, $b) is looser<+> {
return $a * $b;
}

is 2 mul 3 + 4, 14, "'is looser<+>' infix works 1";
is 4 + 3 mul 2 , 14, "'is looser<+>' infix works 2";
}

{
sub infix:<add> ($a, $b) is tighter<*> {
return $a + $b;
}

is 2 * 3 add 4, 14, "'is tighter<*>' infix works 1";
is 4 add 3 * 2 , 14, "'is tighter<*>' infix works 2";
}

{
sub infix:<div> ($a, $b) is equiv(&infix:<*>) {
return $a / $b;
}

ok((4 div 2 * 3) == 6, "'is equiv' works");
ok((4 div 2 * 3) == 6, "'is equiv(&infix:<*>)' works");
}

{
sub infix:<div> ($a, $b) is equiv<*> {
return $a / $b;
}

ok((4 div 2 * 3) == 6, "'is equiv<*>' works");
}



# prefix/postfix precedence

{
Expand Down

0 comments on commit ad5e410

Please sign in to comment.