-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The following test defines some bindings with values in the test expression at the start, but then hardcodes the same values in the expected_ast_node binding value:
Lines 472 to 491 in 3e75565
| fn parse_expression_with_two_different_precedence_binary_operators() { | |
| let outer_left_operand = 1; | |
| let inner_left_operand = 2; | |
| let inner_right_operand = 3; | |
| let mut tokens = VecDeque::from([ | |
| Token::NumericConstant(outer_left_operand), | |
| Token::Plus, | |
| Token::NumericConstant(inner_left_operand), | |
| Token::Asterisk, | |
| Token::NumericConstant(inner_right_operand), | |
| ]); | |
| let expected_ast_node = Expression::Binary { | |
| op: BinaryOperator::Add, | |
| left: Box::new(Expression::NumericConstant(outer_left_operand)), | |
| right: Box::new(Expression::Binary { | |
| op: BinaryOperator::Multiply, | |
| left: Box::new(Expression::NumericConstant(2)), | |
| right: Box::new(Expression::NumericConstant(3)), | |
| }), | |
| }; |
It's best to reuse the bindings and get rid of the hardcoded/magic numbers, to avoid any errors with the hardcoded values going out of sync with the binding values.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels