all tests green
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
82854a58f8
commit
93a1e06a53
5 changed files with 94 additions and 32 deletions
|
|
@ -2,6 +2,29 @@ mod eval_tests {
|
|||
use relish::ast::{eval, lex, SymTable};
|
||||
use relish::ast::{Args, Symbol, Ctr, Seg, ValueType, UserFn};
|
||||
|
||||
#[test]
|
||||
fn eval_simple() {
|
||||
let test_doc = "(1 2)".to_string();
|
||||
let mut syms = SymTable::new();
|
||||
match lex(&test_doc) {
|
||||
Err(e) => {
|
||||
println!("Lexing error: {}\n", e);
|
||||
assert!(false)
|
||||
}
|
||||
|
||||
Ok(initial_ast) => match eval(&initial_ast, &mut syms) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
}
|
||||
|
||||
Ok(reduced) => {
|
||||
assert_eq!(reduced.to_string(), test_doc)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_embedded_lists_no_funcs() {
|
||||
let test_doc = "(1 (1 2 3 4 5) 5)".to_string();
|
||||
|
|
@ -38,11 +61,8 @@ mod eval_tests {
|
|||
value: ValueType::FuncForm( UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: Box::new(Seg::from(
|
||||
Box::new(Ctr::Seg(Seg::from(
|
||||
Box::from(Ctr::Symbol("input".to_string())),
|
||||
Box::from(Ctr::None)))),
|
||||
Box::new(Ctr::None),
|
||||
)),
|
||||
Box::from(Ctr::Symbol("input".to_string())),
|
||||
Box::from(Ctr::None))),
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -80,11 +100,8 @@ mod eval_tests {
|
|||
value: ValueType::FuncForm( UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: Box::new(Seg::from(
|
||||
Box::new(Ctr::Seg(Seg::from(
|
||||
Box::from(Ctr::Symbol("input".to_string())),
|
||||
Box::from(Ctr::None)))),
|
||||
Box::new(Ctr::None),
|
||||
)),
|
||||
Box::from(Ctr::None))),
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue