Eval test doesn't need to be a macro
Can be a fn
This commit is contained in:
parent
47f7eb1ef6
commit
17e88b33f2
@ -508,24 +508,20 @@ mod eval_tests {
|
|||||||
parser.parse()
|
parser.parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! all_output {
|
fn evaluate_all_outputs(input: &str) -> Vec<Result<String, String>> {
|
||||||
($string:expr) => {
|
|
||||||
{
|
|
||||||
let symbol_table = Rc::new(RefCell::new(SymbolTable::new()));
|
let symbol_table = Rc::new(RefCell::new(SymbolTable::new()));
|
||||||
let mut state = State::new(symbol_table);
|
let mut state = State::new(symbol_table);
|
||||||
let ast = parse(tokenize($string)).unwrap();
|
let ast = parse(tokenize(input)).unwrap();
|
||||||
state.symbol_table_handle.borrow_mut().add_top_level_symbols(&ast).unwrap();
|
state.symbol_table_handle.borrow_mut().add_top_level_symbols(&ast).unwrap();
|
||||||
let reduced = ast.reduce(&state.symbol_table_handle.borrow());
|
let reduced = ast.reduce(&state.symbol_table_handle.borrow());
|
||||||
let all_output = state.evaluate(reduced, true);
|
let all_output = state.evaluate(reduced, true);
|
||||||
all_output
|
all_output
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! test_in_fresh_env {
|
macro_rules! test_in_fresh_env {
|
||||||
($string:expr, $correct:expr) => {
|
($string:expr, $correct:expr) => {
|
||||||
{
|
{
|
||||||
let all_output = all_output!($string);
|
let all_output = evaluate_all_outputs($string);
|
||||||
let ref output = all_output.last().unwrap();
|
let ref output = all_output.last().unwrap();
|
||||||
assert_eq!(**output, Ok($correct.to_string()));
|
assert_eq!(**output, Ok($correct.to_string()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user