module scheme import arena fn test_continue_direct_iterations_allocate_only_fixed_entry_storage() { continue_allocation_is_fixed('(define (run n) (do ((i 0 (+ i 1))) ((= i n) 42) (continue) missing))', false) } fn test_continue_vile_scopes_and_temporary_locals_allocate_only_fixed_entry_storage() { continue_allocation_is_fixed('run(n):={for(i:=0,i=0 {continue}\nmissing}\n42}', true) } fn continue_allocation_is_fixed(source string, alternate bool) { mut region := arena.new() region.push() defer { region.pop() region.free() } mut vm := new_with_options(Options{ max_steps: 0, max_frames: 4 }) or { panic(err.msg()) } if alternate { vm.eval_alt(source) or { panic(err.msg()) } } else { vm.eval(source) or { panic(err.msg()) } } run := vm.lookup('run') or { panic(err.msg()) } mut arguments := [integer(1)] vm.call(run, arguments) or { panic(err.msg()) } mut fixed := 0 for count in [1, 101, 10001] { container_store_validated(mut arguments, 0, integer(count)) before := region.used() assert vm.call(run, arguments) or { panic(err.msg()) }.as_integer() or { panic(err.msg()) } == 42 allocated := region.used() - before if fixed == 0 { fixed = allocated } assert allocated == fixed, '${count} iterations: ${allocated} bytes, expected fixed ${fixed}' } }