From 0ca443b1338c2393bae033b295def48b6d7163c8 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sun, 4 Aug 2024 21:39:57 -0400 Subject: [PATCH] Add test --- dust-lang/src/parse.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/dust-lang/src/parse.rs b/dust-lang/src/parse.rs index c143c75..08b6d13 100644 --- a/dust-lang/src/parse.rs +++ b/dust-lang/src/parse.rs @@ -208,6 +208,47 @@ mod tests { use super::*; + #[test] + fn complex_list() { + let input = "[1, 1 + 1, 2 + (4 * 10)]"; + + assert_eq!( + parse(input), + Ok(Instruction::new( + Operation::List(vec![ + Instruction::new(Operation::Constant(Value::integer(1)), (1, 2)), + Instruction::new( + Operation::Add(Box::new(( + Instruction::new(Operation::Constant(Value::integer(1)), (4, 5)), + Instruction::new(Operation::Constant(Value::integer(1)), (8, 9)), + ))), + (4, 9) + ), + Instruction::new( + Operation::Add(Box::new(( + Instruction::new(Operation::Constant(Value::integer(2)), (11, 12)), + Instruction::new( + Operation::Multiply(Box::new(( + Instruction::new( + Operation::Constant(Value::integer(4)), + (16, 17) + ), + Instruction::new( + Operation::Constant(Value::integer(10)), + (20, 22) + ), + ))), + (15, 23) + ), + ))), + (11, 23) + ) + ]), + (0, 24) + )) + ); + } + #[test] fn list() { let input = "[1, 2]";