diff --git a/src/parser.rs b/src/parser.rs index 443ee52..5264cdf 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -569,16 +569,16 @@ mod tests { fn expression_parse_test() { parsetest!("a", &[ExprNode(Variable(ref s))], **s == "a"); 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"); 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"); 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"); 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"); } diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 82e3d8e..e708959 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -180,6 +180,10 @@ mod tests { [NumLiteral(2.3), Operator(OpTok(ref a)), NumLiteral(49.2)], **a == "*"); + token_test!("a+3", + [Identifier(ref a), NumLiteral(3.0)], + **a == "a+"); + assert!(tokenize("2.4.5").is_err()); token_test!("fn my_func(a) { a ? 3[1] }",