add bool var toggle function

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-03-02 12:15:42 -08:00
parent 28e158f110
commit 5ce0a8e8b2
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
6 changed files with 160 additions and 8 deletions

View file

@ -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)";