1
0
Fork 0

Expand unary and assign tests

This commit is contained in:
Vili Sinervä 2025-01-31 13:58:04 +02:00
parent bb3c13372f
commit 385dc98255
No known key found for this signature in database
GPG key ID: DF8FEAF54EFAC996

View file

@ -129,7 +129,16 @@ fn test_binary_op_precedence() {
}
#[test]
fn test_assignment() {
fn test_assignment_basic() {
let result = parse(&tokenize("a = 1 + 2"));
assert_eq!(
result,
BinaryOp(id_ast!("a"), "=", bin_ast!(int_ast!(1), "+", int_ast!(2)))
);
}
#[test]
fn test_assignment_chain() {
let result = parse(&tokenize("a = b = 1 + 2"));
assert_eq!(
result,
@ -142,7 +151,19 @@ fn test_assignment() {
}
#[test]
fn test_unary() {
fn test_unary_basic() {
let result = parse(&tokenize("not x"));
assert_eq!(result, UnaryOp("not", id_ast!("x")));
let result = parse(&tokenize("-x"));
assert_eq!(result, UnaryOp("-", id_ast!("x")));
let result = parse(&tokenize("-1"));
assert_eq!(result, UnaryOp("-", int_ast!(1)));
}
#[test]
fn test_unary_chain() {
let result = parse(&tokenize("not not x"));
assert_eq!(result, UnaryOp("not", un_ast!("not", id_ast!("x"))));