add isset

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-03-06 15:25:23 -08:00
parent de29bbf950
commit 8d6915f69a
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
2 changed files with 57 additions and 0 deletions

View file

@ -222,4 +222,31 @@ mod var_lib_tests {
assert!(false);
}
}
#[test]
fn test_isset_true() {
let doc1 = "(def test '' 1)";
let doc2 = "(set? test)";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
let def_tree = lex(&doc1.to_string()).unwrap();
let set_tree = lex(&doc2.to_string()).unwrap();
eval(&def_tree, &mut syms).unwrap();
if let Ctr::Bool(b) = *eval(&set_tree, &mut syms).unwrap() {
assert!(b);
}
}
#[test]
fn test_isset_false() {
let doc = "(set? test)";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
let set_tree = lex(&doc.to_string()).unwrap();
if let Ctr::Bool(b) = *eval(&set_tree, &mut syms).unwrap() {
assert!(!b);
}
}
}