1
0

Improve logic parsing test

This commit is contained in:
Jeff 2024-02-28 17:02:30 -05:00
parent 4179f6ebe5
commit 4137a1a693

View File

@ -158,6 +158,37 @@ mod tests {
Expression::Value(ValueNode::Integer(1)) Expression::Value(ValueNode::Integer(1))
)))) ))))
); );
assert_eq!(
parse(&lex("(x == 1) && (y == 2)").unwrap()).unwrap()[0].0,
Statement::Expression(Expression::Logic(Box::new(Logic::And(
Expression::Logic(Box::new(Logic::Equal(
Expression::Identifier(Identifier::new("x")),
Expression::Value(ValueNode::Integer(1))
))),
Expression::Logic(Box::new(Logic::Equal(
Expression::Identifier(Identifier::new("y")),
Expression::Value(ValueNode::Integer(2))
))),
))))
);
assert_eq!(
parse(&lex("(x == 1) && (y == 2) && true").unwrap()).unwrap()[0].0,
Statement::Expression(Expression::Logic(Box::new(Logic::And(
Expression::Logic(Box::new(Logic::And(
Expression::Logic(Box::new(Logic::Equal(
Expression::Identifier(Identifier::new("x")),
Expression::Value(ValueNode::Integer(1))
))),
Expression::Logic(Box::new(Logic::Equal(
Expression::Identifier(Identifier::new("y")),
Expression::Value(ValueNode::Integer(2))
))),
))),
Expression::Value(ValueNode::Boolean(true))
))))
);
} }
#[test] #[test]