Skip to content

Commit

Permalink
fix: Env test case
Browse files Browse the repository at this point in the history
  • Loading branch information
can-keklik committed Dec 29, 2023
1 parent 3bf5b8a commit b9d108e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/src/runtime/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ mod test {
assert_eq!(child.borrow().read("five").unwrap(), RV::Num(5.0));
}

#[test]
fn test_write_to_parent() {
let parent = super::Environment::new(None);
parent
.borrow_mut()
.declare("five".to_string(), RV::Num(5.0));
let child = super::Environment::new(Some(parent.clone()));
child
.borrow_mut()
.assign("five".to_string(), RV::Num(5.1))
.unwrap();
assert_eq!(parent.borrow().read("five").unwrap(), RV::Num(5.1));
assert_eq!(child.borrow().read("five").unwrap(), RV::Num(5.1));
}

#[test]
fn test_read_undefined_variable() {
let env = super::Environment::new(None);
Expand Down

0 comments on commit b9d108e

Please sign in to comment.