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

Function test_reset_preserves_call_stack_limit

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

Source from the content-addressed store, hash-verified

1146
1147 #[tokio::test]
1148 async fn test_reset_preserves_call_stack_limit() {
1149 let compiler = Compiler::new(&HashMap::default(), &[]).unwrap();
1150 let image = compiler
1151 .compile(
1152 &mut br#"
1153 SUB recurse(n%)
1154 IF n < 20 THEN
1155 recurse n + 1
1156 END IF
1157 END SUB
1158
1159 recurse 0
1160 "#
1161 .as_slice(),
1162 )
1163 .unwrap();
1164 let mut vm = Vm::new_with_limits(
1165 HashMap::default(),
1166 Limits { max_call_stack: 8, max_heap_entries: U24::MAX },
1167 );
1168
1169 match vm.exec(&image) {
1170 StopReason::Exception(_, msg) if msg == "Out of call stack space" => (),
1171 _ => panic!("Execution should stop when the call stack limit is reached"),
1172 }
1173
1174 vm.reset();
1175
1176 match vm.exec(&image) {
1177 StopReason::Exception(_, msg) if msg == "Out of call stack space" => (),
1178 _ => panic!("Execution should preserve the configured call stack limit after reset"),
1179 }
1180 }
1181
1182 #[tokio::test]
1183 async fn test_scope_get_pos_no_args() {

Callers

nothing calls this directly

Calls 4

compileMethod · 0.45
as_sliceMethod · 0.45
execMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected