Commits

Anonymous committed 77d5d05

more binary expression tests

Comments (0)

Files changed (1)

tests/samples/test_js_expressions.py

             
     def test_binary(self):
         self.checkAst(r'1 * 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='*', rule="ShiftExpression")
+        self.checkAst(r'1 /  2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "," "], op='/', rule="ShiftExpression")
+        # self.checkAst(r'1 \t% 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" ","\t"], postfix=[" "], op='%', rule="ShiftExpression")
+        # self.checkAst(r'1 +\n 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=["\n"," "], op='+', rule="ShiftExpression")
+        self.checkAst(r'1 - 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='-', rule="ShiftExpression")
+        self.checkAst(r'1 << 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='<<', rule="ShiftExpression")
+        self.checkAst(r'1 >>> 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='>>>', rule="ShiftExpression")
+        self.checkAst(r'1 >> 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='>>', rule="ShiftExpression")
 
-        # testExpression("1 * 2",  [ "BinaryExpr", {op: "*"  }, Expr("1"), Expr("2") ]);
-        # testExpression("1 / 2",  [ "BinaryExpr", {op: "/"  }, Expr("1"), Expr("2") ]);
-        # testExpression("1 % 2",  [ "BinaryExpr", {op: "%"  }, Expr("1"), Expr("2") ]);
-        # testExpression("1 + 2",  [ "BinaryExpr", {op: "+"  }, Expr("1"), Expr("2") ]);
-        # testExpression("1 - 2",  [ "BinaryExpr", {op: "-"  }, Expr("1"), Expr("2") ]);
-        # testExpression("1 << 2", [ "BinaryExpr", {op: "<<" }, Expr("1"), Expr("2") ]);
-        # testExpression("1 >>> 2",[ "BinaryExpr", {op: ">>>"}, Expr("1"), Expr("2") ]);
-        # testExpression("1 >> 2", [ "BinaryExpr", {op: ">>" }, Expr("1"), Expr("2") ]);
+        # self.checkAst(r'1 < 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='<', rule="RelationalExpression")
+        # self.checkAst(r'1 > 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='>', rule="RelationalExpression")
+        # self.checkAst(r'1 <= 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='<=', rule="RelationalExpression")
+        # self.checkAst(r'1 >= 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='>=', rule="RelationalExpression")
+        # self.checkAst(r'1 instanceof 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='instanceof', rule="RelationalExpression")
+        # self.checkAst(r'1 in 2', "BinaryExpr", SimpleLiteral("number","1").toAST(), SimpleLiteral("number","2").toAST(), prefix=[" "], postfix=[" "], op='in', rule="RelationalExpression")
 
         # // test precedence
         # testExpression("1 * 2 + 3", // * precedes +