variables defined using def in a let statement now escape local scope
test added as well.
This commit is contained in:
parent
3848d3bcfa
commit
2dfe73de6b
3 changed files with 37 additions and 0 deletions
|
|
@ -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'))";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue