| 1 | module scheme |
| 2 | |
| 3 | import arena |
| 4 | |
| 5 | fn test_bounded_rest_spines_allocate_only_their_pair_cells() { |
| 6 | mut instance := new_bounded(Options{}, arena.ChunkLimits{ max_live_bytes: 8 * 1024 * 1024 })! |
| 7 | defer { instance.close() or { panic(err) } } |
| 8 | instance.run(fn (mut vm VM) !Value { |
| 9 | for count in [0, 1, 3, 4, 65] { |
| 10 | items := []Value{len: count, init: integer(42)} |
| 11 | // Start on a whole-pair boundary so unrelated cursor padding is |
| 12 | // excluded from the allocation contract being measured. |
| 13 | unsafe { arena.current_allocator().calloc(int(sizeof(Pair))) } |
| 14 | before, _ := v_arena_stats(v_arena_current()) |
| 15 | value := vm.owner.bounded_files.argument_list(items)! |
| 16 | after, _ := v_arena_stats(v_arena_current()) |
| 17 | assert after - before == count * int(sizeof(Pair)) |
| 18 | assert value.list_length()! == count |
| 19 | if count > 0 { assert value.pair_pointer().car.as_integer()! == 42 } |
| 20 | } |
| 21 | return unspecified() |
| 22 | })! |
| 23 | } |
| 24 | |