diff options
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/tests.rs')
-rw-r--r-- | users/tazjin/rlox/src/bytecode/tests.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/users/tazjin/rlox/src/bytecode/tests.rs b/users/tazjin/rlox/src/bytecode/tests.rs index 5a0901be6d79..d9a752b38788 100644 --- a/users/tazjin/rlox/src/bytecode/tests.rs +++ b/users/tazjin/rlox/src/bytecode/tests.rs @@ -1,12 +1,17 @@ +use super::value::Value; use super::*; use crate::Lox; -fn expect_num(code: &str, value: f64) { +fn expect(code: &str, value: Value) { let result = Interpreter::create() .interpret(code.into()) .expect("evaluation failed"); - assert_eq!(result, value::Value::Number(value)); + assert_eq!(result, value); +} + +fn expect_num(code: &str, value: f64) { + expect(code, Value::Number(value)) } #[test] @@ -46,3 +51,10 @@ fn arithmetic() { expect_num("-4 * -4 + (14 - 5)", 25.0); expect_num("(702 + 408) - ((239 - 734) / -5) + -4", 1007.0); } + +#[test] +fn trivial_literals() { + expect("true", Value::Bool(true)); + expect("false", Value::Bool(false)); + expect("nil", Value::Nil); +} |