()
| 660 | Alloc(inner) -> { return 8 } |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | if OwnedString_length(&s) != 8 { return 9 } |
| 665 | |
| 666 | OwnedString_clear(&s) |
| 667 | if OwnedString_length(&s) != 0 { return 10 } |
| 668 | OwnedString_deinit(&s) |
| 669 | return 0 |
| 670 | } |
| 671 | "#, |
| 672 | ); |
| 673 | assert_eq!(exit, Some(0)); |
| 674 | } |
| 675 | |
| 676 | #[test] |
| 677 | fn hosted_arena_bumps_resets_and_reuses() { |
| 678 | let (_, exit) = run_hll( |
| 679 | r#" |
| 680 | memory_allocator := import("memory_allocator") |
| 681 | |
| 682 | main: () -> i32 { |
| 683 | a: Arena = { .head = null } |
| 684 | Arena_init(&a) |
| 685 | |
| 686 | first: u8* = null |
| 687 | first_result := Arena_alloc(&a, 24, 8) |
| 688 | match first_result { |
| 689 | Ok(value) -> { first = value } |
| 690 | Err(error) -> { return 1 } |
| 691 | } |
| 692 | if (first as u64) % 8 != 0 { return 2 } |
| 693 | first[0] = 7 |
| 694 | |
| 695 | second: u8* = null |
| 696 | second_result := Arena_alloc(&a, 40, 64) |
| 697 | match second_result { |
| 698 | Ok(value) -> { second = value } |
| 699 | Err(error) -> { return 3 } |
| 700 | } |
| 701 | if (second as u64) % 64 != 0 { return 4 } |
| 702 | if second == first { return 5 } |
| 703 | |
| 704 | ; Larger than the default chunk: gets its own chunk. |
| 705 | big_result := Arena_alloc(&a, 8192, 8) |
| 706 | match big_result { |
| 707 | Ok(value) -> {} |
| 708 | Err(error) -> { return 6 } |
| 709 | } |
| 710 |
nothing calls this directly
no test coverage detected