Add full test

Test evaluate, tokenize, parser all at once
This commit is contained in:
greg 2015-12-30 23:30:50 -08:00
parent 971ab9ba21
commit 8c0ac19fa8

View File

@ -73,8 +73,21 @@ fn reduce_step(ast: AST) -> EvaluatorResult<AST> {
} }
} }
pub fn evaluate(ast: AST) -> String { pub fn evaluate(ast: AST) -> String {
let ev = Evaluator { ast: ast }; let ev = Evaluator { ast: ast };
ev.run() ev.run()
} }
#[cfg(test)]
mod tests {
use tokenizer::tokenize;
use parser::{parse, AST};
use super::evaluate;
#[test]
fn test_basic_evaluation() {
let input = "1 + 2\n";
let output = evaluate(parse(tokenize(input)).unwrap());
assert_eq!(output, "3");
}
}