Expand unary and assign tests
This commit is contained in:
parent
385dc98255
commit
ca254a34c6
1 changed files with 12 additions and 0 deletions
|
@ -160,6 +160,12 @@ fn test_unary_basic() {
|
||||||
|
|
||||||
let result = parse(&tokenize("-1"));
|
let result = parse(&tokenize("-1"));
|
||||||
assert_eq!(result, UnaryOp("-", int_ast!(1)));
|
assert_eq!(result, UnaryOp("-", int_ast!(1)));
|
||||||
|
|
||||||
|
let result = parse(&tokenize("-1 + 2"));
|
||||||
|
assert_eq!(
|
||||||
|
result,
|
||||||
|
BinaryOp(un_ast!("-", int_ast!(1)), "+", int_ast!(2))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -172,6 +178,12 @@ fn test_unary_chain() {
|
||||||
|
|
||||||
let result = parse(&tokenize("--1"));
|
let result = parse(&tokenize("--1"));
|
||||||
assert_eq!(result, UnaryOp("-", un_ast!("-", int_ast!(1))));
|
assert_eq!(result, UnaryOp("-", un_ast!("-", int_ast!(1))));
|
||||||
|
|
||||||
|
let result = parse(&tokenize("--1 + 2"));
|
||||||
|
assert_eq!(
|
||||||
|
result,
|
||||||
|
BinaryOp(un_ast!("-", un_ast!("-", int_ast!(1))), "+", int_ast!(2))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Reference in a new issue