variables defined using def in a let statement now escape local scope

test added as well.
This commit is contained in:
Ava Apples Affine 2023-03-17 12:01:43 -07:00
parent 3848d3bcfa
commit 2dfe73de6b
Signed by: affine
GPG key ID: 3A4645B8CF806069
3 changed files with 37 additions and 0 deletions

View file

@ -65,6 +65,26 @@ mod control_lib_tests {
);
}
#[test]
fn test_let_def_escapes_locals() {
let document1 = "(let (
(temp 'hello')
(temp (concat temp ' ' 'world')))
(def global '' temp))";
let document2 = "global";
let result = "('hello world')";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
eval(&lex(&document1.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(
*eval(&lex(&document2.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
fn test_let_multibody_evals() {
let document = "(let ((temp '1')) temp (cons () temp '2'))";