diff --git a/src/run.rs b/src/run.rs index d8f3b13..5f99450 100644 --- a/src/run.rs +++ b/src/run.rs @@ -84,3 +84,24 @@ impl Eval for Expression { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::ast; + + #[test] + fn test_consts() { + let mut scope = Scope::default(); + assert_eq!(ast::Constant::Nil.eval(&mut scope), None); + assert_eq!( + ast::Constant::Boolean(true).eval(&mut scope), + Some(true.into()) + ); + assert_eq!(ast::Constant::Number(42).eval(&mut scope), Some(42.into())); + assert_eq!( + ast::Constant::String("foobar".into()).eval(&mut scope), + Some("foobar".into()) + ); + } +}