Add support for all left-associative binary ops
This commit is contained in:
parent
04e390c6f9
commit
0691c22487
2 changed files with 33 additions and 1 deletions
|
@ -64,6 +64,31 @@ fn test_binary_op_basic() {
|
|||
assert_eq!(result, BinaryOp(int_ast!(1), "/", int_ast!(2)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_binary_op_all_levels() {
|
||||
let result = parse(&tokenize("1 * 2 + 3 < 4 == 5 and 6 or 7"));
|
||||
assert_eq!(
|
||||
result,
|
||||
BinaryOp(
|
||||
bin_ast!(
|
||||
bin_ast!(
|
||||
bin_ast!(
|
||||
bin_ast!(bin_ast!(int_ast!(1), "*", int_ast!(2)), "+", int_ast!(3)),
|
||||
"<",
|
||||
int_ast!(4)
|
||||
),
|
||||
"==",
|
||||
int_ast!(5)
|
||||
),
|
||||
"and",
|
||||
int_ast!(6)
|
||||
),
|
||||
"or",
|
||||
int_ast!(7)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_binary_op_identifier() {
|
||||
let result = parse(&tokenize("a + 1"));
|
||||
|
|
Reference in a new issue