Start trying to fix tests

This commit is contained in:
greg 2018-06-04 20:36:26 -07:00
parent f98d8e2bb0
commit f1679e83b7
2 changed files with 7 additions and 2 deletions

View File

@ -323,7 +323,9 @@ mod eval_tests {
($string:expr, $correct:expr) => { ($string:expr, $correct: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 all_output = state.evaluate(parse(tokenize($string)).0.unwrap().reduce(), true); let ast = parse(tokenize($string)).0.unwrap();
state.symbol_table_handle.borrow_mut().add_top_level_symbols(&ast);
let all_output = state.evaluate(ast.reduce(), true);
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()));
} }

View File

@ -469,11 +469,14 @@ mod tests {
use super::{Type, TConst, TypeContext}; use super::{Type, TConst, TypeContext};
use super::Type::*; use super::Type::*;
use super::TConst::*; use super::TConst::*;
use std::rc::Rc;
use std::cell::RefCell;
macro_rules! type_test { macro_rules! type_test {
($input:expr, $correct:expr) => { ($input:expr, $correct:expr) => {
{ {
let mut tc = TypeContext::new(); let symbol_table = Rc::new(RefCell::new(SymbolTable::new()));
let mut tc = TypeContext::new(symbol_table);
let ast = ::ast::parse(::tokenizing::tokenize($input)).0.unwrap() ; let ast = ::ast::parse(::tokenizing::tokenize($input)).0.unwrap() ;
//tc.add_symbols(&ast); //tc.add_symbols(&ast);
assert_eq!($correct, tc.infer_block(&ast.0).unwrap()) assert_eq!($correct, tc.infer_block(&ast.0).unwrap())