From d640c815a8b8752992640105173b707d4a3868fd Mon Sep 17 00:00:00 2001 From: Ava Hahn Date: Fri, 24 Feb 2023 15:45:27 -0800 Subject: [PATCH] add eval test Signed-off-by: Ava Hahn --- tests/test_eval.rs | 54 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/tests/test_eval.rs b/tests/test_eval.rs index a9d3cc2..cc3d3d3 100644 --- a/tests/test_eval.rs +++ b/tests/test_eval.rs @@ -2,31 +2,6 @@ mod eval_tests { use relish::ast::{eval, lex, SymTable}; use relish::ast::{Args, Symbol, Ctr, Seg, ValueType, UserFn}; - // TODO: write generalized testing routine on top of list of inputs - - #[test] - fn eval_singlet() { - let test_doc = "(1)".to_string(); - let mut syms = SymTable::new(); - match lex(&test_doc) { - Err(e) => { - println!("Lexing error: {}\n", e); - assert!(false) - } - - Ok(ref initial_ast) => match eval(initial_ast, &mut syms) { - Err(e) => { - println!("Evaluation error: {}\n", e); - assert!(false) - } - - Ok(reduced) => { - assert_eq!(reduced.to_string(), test_doc) - } - }, - } - } - #[test] fn eval_embedded_lists_no_funcs() { let test_doc = "(1 (1 2 3 4 5) 5)".to_string(); @@ -133,16 +108,27 @@ mod eval_tests { } } - /* #[test] - fn eval_bad_vars() { - } + fn eval_bad_syms() { + let test_doc = "(undefined)".to_string(); + let mut syms = SymTable::new(); + match lex(&test_doc) { + Err(e) => { + println!("Lexing error: {}\n", e); + assert!(false) + } - #[test] - fn eval_bad_func() { - } + Ok(initial_ast) => match eval(&initial_ast, &mut syms) { + Err(e) => { + assert_eq!(e,"error in call to undefined: undefined symbol: undefined") + } - #[test] - fn eval_verify_all_elems_cloned() { - }*/ + Ok(reduced) => { + println!("Eval succeeded when it shouldnt have"); + println!("see: {}", reduced); + assert!(false) + } + }, + } + } }