From b9d108e590bfef984666173256f54b76f0a4cc7b Mon Sep 17 00:00:00 2001 From: Vedat Can Keklik Date: Fri, 29 Dec 2023 15:34:14 +0300 Subject: [PATCH] fix: Env test case --- server/src/runtime/environment.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/src/runtime/environment.rs b/server/src/runtime/environment.rs index bdbba58f..e477bded 100644 --- a/server/src/runtime/environment.rs +++ b/server/src/runtime/environment.rs @@ -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);