finished let forms

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-03-01 15:17:50 -08:00
parent 131008c3a2
commit c1d83a6285
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
5 changed files with 198 additions and 27 deletions

View file

@ -62,4 +62,72 @@ mod control_lib_tests {
assert!(false);
}
}
#[test]
fn test_let_multiphase_locals() {
let document = "(let (
(temp '1')
(temp (append () temp '2')))
temp)";
let result = "('1' '2')";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
if let Ok(tree) = lex(&document.to_string()) {
if let Ctr::Seg(ref i) = *eval(&tree, &mut syms).unwrap() {
assert_eq!(i.to_string(), result);
} else {
assert!(false);
}
} else {
assert!(false);
}
}
#[test]
fn test_let_multibody_evals() {
let document = "(let ((temp '1')) temp (append () temp '2'))";
let result = "('1' '2')";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
if let Ok(tree) = lex(&document.to_string()) {
if let Ctr::Seg(ref i) = *eval(&tree, &mut syms).unwrap() {
assert_eq!(i.to_string(), result);
} else {
assert!(false);
}
} else {
assert!(false);
}
}
#[test]
fn test_let_multiphase_local_multibody_evals() {
let document = "(let (
(temp '1')
(temp (append () temp '2')))
(echo 'first body')
(append temp '3'))";
let result = "('1' '2' '3')";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
if let Ok(tree) = lex(&document.to_string()) {
if let Ctr::Seg(ref i) = *eval(&tree, &mut syms).unwrap() {
assert_eq!(i.to_string(), result);
} else {
assert!(false);
}
} else {
assert!(false);
}
}
}