better eval and test for eval,quote

This commit is contained in:
Ava Apples Affine 2023-03-11 22:04:46 -08:00
parent 6daf0867df
commit 640a53cad8
Signed by: affine
GPG key ID: 3A4645B8CF806069
4 changed files with 72 additions and 8 deletions

View file

@ -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(),
);
}
}