MCPcopy Index your code
hub / github.com/endbasic/endbasic / test_interrupt_parks_execution_at_eof

Function test_interrupt_parks_execution_at_eof

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

Source from the content-addressed store, hash-verified

1077
1078 #[tokio::test]
1079 async fn test_interrupt_parks_execution_at_eof() {
1080 let data = Rc::from(RefCell::from(vec![]));
1081 let mut upcalls_by_name: HashMap<SymbolKey, Rc<dyn Callable>> = HashMap::new();
1082 upcalls_by_name.insert(SymbolKey::from("OUT"), OutCommand::new(data.clone()));
1083
1084 let compiler = Compiler::new(&upcalls_by_name, &[]).unwrap();
1085 let image = compiler.compile(&mut b"OUT 1: OUT 2".as_slice()).unwrap();
1086 let mut vm = Vm::new(upcalls_by_name);
1087
1088 match vm.exec(&image) {
1089 StopReason::Eof => (),
1090 _ => panic!("Execution should stop at EOF"),
1091 }
1092 assert_eq!(["1", "2"], *data.borrow().as_slice());
1093
1094 vm.interrupt(&image);
1095 match vm.exec(&image) {
1096 StopReason::Eof => (),
1097 _ => panic!("Execution should be parked at EOF after interruption"),
1098 }
1099 assert_eq!(["1", "2"], *data.borrow().as_slice());
1100 }
1101
1102 #[tokio::test]
1103 async fn test_clear_resets_runtime_state() {

Callers

nothing calls this directly

Calls 5

interruptMethod · 0.80
insertMethod · 0.45
compileMethod · 0.45
as_sliceMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected