MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / cross_module_la_works

Function cross_module_la_works

tests/integration/platform_stdlib.rs:711–761  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

709 }
710
711 bad := Arena_alloc(&a, 8, 3)
712 match bad {
713 Ok(value) -> { return 7 }
714 Err(error) -> {
715 match error {
716 InvalidAlignment -> {}
717 OutOfMemory -> { return 8 }
718 SizeOverflow -> { return 9 }
719 }
720 }
721 }
722
723 ; Reset keeps the chunks: the next allocation reuses their storage.
724 Arena_reset(&a)
725 reused: u8* = null
726 reused_result := Arena_alloc(&a, 24, 8)
727 match reused_result {
728 Ok(value) -> { reused = value }
729 Err(error) -> { return 10 }
730 }
731 if reused == null { return 11 }
732
733 Arena_deinit(&a)
734 if a.head != null { return 12 }
735 return 0
736}
737"#,
738 );
739 assert_eq!(exit, Some(0));
740}
741
742#[test]
743fn hosted_pool_allocates_releases_and_rejects_invalid() {
744 let (_, exit) = run_hll(
745 r#"
746memory_allocator := import("memory_allocator")
747
748main: () -> i32 {
749 p: Pool<i64> = { .chunks = null }
750 Pool_init<i64>(&p)
751
752 a: i64* = null
753 a_result := Pool_alloc<i64>(&p)
754 match a_result {
755 Ok(value) -> { a = value }
756 Err(error) -> { return 1 }
757 }
758 b: i64* = null
759 b_result := Pool_alloc<i64>(&p)
760 match b_result {
761 Ok(value) -> { b = value }
762 Err(error) -> { return 2 }
763 }
764 if a == b { return 3 }

Callers

nothing calls this directly

Calls 9

compile_stdlib_objectsFunction · 0.85
set_write_artifactsMethod · 0.80
assemble_namedMethod · 0.80
collectMethod · 0.80
pushMethod · 0.80
compileMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected