From 17e88b33f23293d87bd72070574290e74862060e Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 5 Nov 2018 21:07:06 -0800 Subject: [PATCH] Eval test doesn't need to be a macro Can be a fn --- schala-lang/language/src/eval.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index 576d154..c3c99ee 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -508,24 +508,20 @@ mod eval_tests { parser.parse() } - macro_rules! all_output { - ($string:expr) => { - { - let symbol_table = Rc::new(RefCell::new(SymbolTable::new())); - let mut state = State::new(symbol_table); - let ast = parse(tokenize($string)).unwrap(); - state.symbol_table_handle.borrow_mut().add_top_level_symbols(&ast).unwrap(); - let reduced = ast.reduce(&state.symbol_table_handle.borrow()); - let all_output = state.evaluate(reduced, true); - all_output - } - } + fn evaluate_all_outputs(input: &str) -> Vec> { + let symbol_table = Rc::new(RefCell::new(SymbolTable::new())); + let mut state = State::new(symbol_table); + let ast = parse(tokenize(input)).unwrap(); + state.symbol_table_handle.borrow_mut().add_top_level_symbols(&ast).unwrap(); + let reduced = ast.reduce(&state.symbol_table_handle.borrow()); + let all_output = state.evaluate(reduced, true); + all_output } macro_rules! test_in_fresh_env { ($string:expr, $correct:expr) => { { - let all_output = all_output!($string); + let all_output = evaluate_all_outputs($string); let ref output = all_output.last().unwrap(); assert_eq!(**output, Ok($correct.to_string())); }