Add test for "a+4" being conterintuitive
Also fix Op -> BinOp in tests
This commit is contained in:
parent
9454fc6194
commit
2681dbc4f2
@ -569,16 +569,16 @@ mod tests {
|
|||||||
fn expression_parse_test() {
|
fn expression_parse_test() {
|
||||||
parsetest!("a", &[ExprNode(Variable(ref s))], **s == "a");
|
parsetest!("a", &[ExprNode(Variable(ref s))], **s == "a");
|
||||||
parsetest!("a + b",
|
parsetest!("a + b",
|
||||||
&[ExprNode(BinExp(Op::Plus, box Variable(ref a), box Variable(ref b)))],
|
&[ExprNode(BinExp(BinOp::Add, box Variable(ref a), box Variable(ref b)))],
|
||||||
**a == "a" && **b == "b");
|
**a == "a" && **b == "b");
|
||||||
parsetest!("a + b * c",
|
parsetest!("a + b * c",
|
||||||
&[ExprNode(BinExp(Op::Plus, box Variable(ref a), box BinExp(Op::Mul, box Variable(ref b), box Variable(ref c))))],
|
&[ExprNode(BinExp(BinOp::Add, box Variable(ref a), box BinExp(BinOp::Mul, box Variable(ref b), box Variable(ref c))))],
|
||||||
**a == "a" && **b == "b" && **c == "c");
|
**a == "a" && **b == "b" && **c == "c");
|
||||||
parsetest!("a * b + c",
|
parsetest!("a * b + c",
|
||||||
&[ExprNode(BinExp(Op::Plus, box BinExp(Op::Mul, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))],
|
&[ExprNode(BinExp(BinOp::Add, box BinExp(BinOp::Mul, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))],
|
||||||
**a == "a" && **b == "b" && **c == "c");
|
**a == "a" && **b == "b" && **c == "c");
|
||||||
parsetest!("(a + b) * c",
|
parsetest!("(a + b) * c",
|
||||||
&[ExprNode(BinExp(Op::Mul, box BinExp(Op::Plus, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))],
|
&[ExprNode(BinExp(BinOp::Mul, box BinExp(BinOp::Add, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))],
|
||||||
**a == "a" && **b == "b" && **c == "c");
|
**a == "a" && **b == "b" && **c == "c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +180,10 @@ mod tests {
|
|||||||
[NumLiteral(2.3), Operator(OpTok(ref a)), NumLiteral(49.2)],
|
[NumLiteral(2.3), Operator(OpTok(ref a)), NumLiteral(49.2)],
|
||||||
**a == "*");
|
**a == "*");
|
||||||
|
|
||||||
|
token_test!("a+3",
|
||||||
|
[Identifier(ref a), NumLiteral(3.0)],
|
||||||
|
**a == "a+");
|
||||||
|
|
||||||
assert!(tokenize("2.4.5").is_err());
|
assert!(tokenize("2.4.5").is_err());
|
||||||
|
|
||||||
token_test!("fn my_func(a) { a ? 3[1] }",
|
token_test!("fn my_func(a) { a ? 3[1] }",
|
||||||
|
Loading…
Reference in New Issue
Block a user