diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_execution.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_execution.rs b/tests/test_execution.rs new file mode 100644 index 0000000..dd1b038 --- /dev/null +++ b/tests/test_execution.rs @@ -0,0 +1,21 @@ +use chrysanthemum::ast::*; +use chrysanthemum::simple::*; +use chrysanthemum::util::*; + +#[test] +fn test_simple() { + assert_eq!(execute(Context::new(), Const(0, Type::Boolean)), Ok(Term(0, Type::Boolean))); + assert_eq!(execute(Context::new(), Const(123, Type::Natural)), Ok(Term(123, Type::Natural))); + assert_eq!(execute(Context::new(), Const(123, Type::Integer)), Ok(Term(123, Type::Integer))); + assert!(execute(Context::new(), Var("x")).is_err()); +} + +#[test] +fn test_complex() { + let mut context = Context::new(); + context.insert(String::from("x"), Term(413, Type::Natural)); + context.insert(String::from("y"), Term(1, Type::Boolean)); + assert_eq!(execute(context.clone(), Var("x")), Ok(Term(413, Type::Natural))); + assert_eq!(execute(context.clone(), Cond(Var("y"), Const(612, Type::Integer), Var("x"))), Ok(Term(612, Type::Integer))); + assert_eq!(execute(context.clone(), App(Abs("z", Cond(Const(0, Type::Boolean), Var("x"), Var("z"))), Const(1025, Type::Integer))), Ok(Term(1025, Type::Integer))); +} |