add bool var toggle function
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
28e158f110
commit
5ce0a8e8b2
6 changed files with 160 additions and 8 deletions
|
|
@ -40,6 +40,43 @@ mod var_lib_tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_func_def_and_lookup() {
|
||||
let doc1 = "(def test (hello) hello)";
|
||||
let doc2 = "(test '1')";
|
||||
let result = "1";
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
|
||||
if let Ok(tree) = lex(&doc1.to_string()) {
|
||||
let eval_result = *eval(&tree, &mut syms).unwrap();
|
||||
if let Ctr::None = eval_result {
|
||||
// pass
|
||||
} else {
|
||||
eprintln!("bad: {eval_result}");
|
||||
assert!(false);
|
||||
}
|
||||
} else {
|
||||
eprintln!("couldn't lex doc1");
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
if let Ok(tree) = lex(&doc2.to_string()) {
|
||||
let eval_result = *eval(&tree, &mut syms).unwrap();
|
||||
if let Ctr::String(ref i) = eval_result {
|
||||
assert_eq!(i.to_string(), result);
|
||||
} else {
|
||||
eprintln!("bad: {eval_result}");
|
||||
assert!(false);
|
||||
}
|
||||
} else {
|
||||
eprintln!("couldn't lex doc2");
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_variable_def_redef_and_lookup() {
|
||||
let doc1 = "(def test 1)";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue