better eval and test for eval,quote
This commit is contained in:
parent
6daf0867df
commit
640a53cad8
4 changed files with 72 additions and 8 deletions
|
|
@ -265,4 +265,36 @@ mod var_lib_tests {
|
|||
eval(&env_tree, &mut syms).unwrap();
|
||||
eval(&tst_tree, &mut syms).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_quote() {
|
||||
let document = "(quote (add 1 2))";
|
||||
let result = "(add 1 2)";
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
assert_eq!(
|
||||
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
result.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_eval() {
|
||||
let document = "
|
||||
(let ((stored-tree (quote (add 1 2))))
|
||||
(eval stored-tree)))";
|
||||
let result = "3";
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
assert_eq!(
|
||||
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
result.to_string(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue