Add full test
Test evaluate, tokenize, parser all at once
This commit is contained in:
parent
971ab9ba21
commit
8c0ac19fa8
@ -73,8 +73,21 @@ fn reduce_step(ast: AST) -> EvaluatorResult<AST> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn evaluate(ast: AST) -> String {
|
||||
let ev = Evaluator { ast: ast };
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user