-
-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix OpIn precedence: it's actually the lowest one. closes #6531
- Loading branch information
Showing
3 changed files
with
57 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package unit.issues; | ||
|
||
import haxe.macro.Expr; | ||
import haxe.macro.ExprTools; | ||
import haxe.macro.Printer; | ||
|
||
class Issue6531 extends unit.Test { | ||
function test() { | ||
peq(macro a in b in c, "(a in (b in c))"); | ||
peq(macro a % b in c, "(a % (b in c))"); | ||
peq(macro a * b in c, "(a * (b in c))"); | ||
peq(macro a / b in c, "(a / (b in c))"); | ||
peq(macro a + b in c, "(a + (b in c))"); | ||
peq(macro a - b in c, "(a - (b in c))"); | ||
peq(macro a << b in c, "(a << (b in c))"); | ||
peq(macro a >> b in c, "(a >> (b in c))"); | ||
peq(macro a >>> b in c, "(a >>> (b in c))"); | ||
peq(macro a | b in c, "(a | (b in c))"); | ||
peq(macro a & b in c, "(a & (b in c))"); | ||
peq(macro a ^ b in c, "(a ^ (b in c))"); | ||
peq(macro a == b in c, "(a == (b in c))"); | ||
peq(macro a != b in c, "(a != (b in c))"); | ||
peq(macro a > b in c, "(a > (b in c))"); | ||
peq(macro a >= b in c, "(a >= (b in c))"); | ||
peq(macro a < b in c, "(a < (b in c))"); | ||
peq(macro a <= b in c, "(a <= (b in c))"); | ||
peq(macro a...b in c, "(a ... (b in c))"); | ||
peq(macro a || b in c, "(a || (b in c))"); | ||
peq(macro a && b in c, "(a && (b in c))"); | ||
peq(macro a => b in c, "(a => (b in c))"); | ||
peq(macro a = b in c, "(a = (b in c))"); | ||
peq(macro a += b in c, "(a += (b in c))"); | ||
} | ||
|
||
function peq(e, s) eq(new Printer().printExpr(parentize(e)), s); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
static function parentize(e:Expr):Expr { | ||
return switch e.expr { | ||
case EConst(_): e; | ||
case _: | ||
e = ExprTools.map(e, parentize); | ||
{expr: EParenthesis(e), pos: e.pos}; | ||
} | ||
} | ||
} |
BTW I find this a nice way to test precedence. I wonder if we have more precedence tests. If not, this can be reused for that.