MCPcopy Create free account
hub / github.com/endbasic/endbasic / test_clear_preserves_upcall_caches

Function test_clear_preserves_upcall_caches

core/src/vm/mod.rs:1123–1145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1121
1122 #[tokio::test]
1123 async fn test_clear_preserves_upcall_caches() {
1124 let data = Rc::from(RefCell::from(vec![]));
1125 let mut upcalls_by_name: HashMap<SymbolKey, Rc<dyn Callable>> = HashMap::new();
1126 upcalls_by_name.insert(SymbolKey::from("OUT"), OutCommand::new(data.clone()));
1127
1128 let compiler = Compiler::new(&upcalls_by_name, &[]).unwrap();
1129 let image = compiler.compile(&mut b"OUT 3".as_slice()).unwrap();
1130 let mut vm = Vm::new(upcalls_by_name);
1131
1132 match vm.exec(&image) {
1133 StopReason::Eof => (),
1134 _ => panic!("Execution should stop at EOF"),
1135 }
1136 assert_eq!(["3"], *data.borrow().as_slice());
1137
1138 vm.clear();
1139
1140 match vm.exec(&image) {
1141 StopReason::Eof => (),
1142 _ => panic!("Execution should still stop at EOF after clear"),
1143 }
1144 assert_eq!(["3", "3"], *data.borrow().as_slice());
1145 }
1146
1147 #[tokio::test]
1148 async fn test_reset_preserves_call_stack_limit() {

Callers

nothing calls this directly

Calls 5

insertMethod · 0.45
compileMethod · 0.45
as_sliceMethod · 0.45
execMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected