Add Implicit @pool for Each Unit Test Invocation (#2654)

* Add Implicit `@pool` for Each Unit Test Invocation
This commit is contained in:
Zack Puhl
2025-12-17 09:08:02 -05:00
committed by GitHub
parent 00c1210625
commit 8055c340f6
3 changed files with 40 additions and 8 deletions

View File

@@ -0,0 +1,26 @@
module runtime_test_tests @test;
import std::core::runtime @public;
import std::core::mem::allocator @public;
import std::math::random;
fn void tmem_shouldnt_leak_if_no_pool()
{
for (usz i = 0; i < 256; i++)
{
char[] my_arr = mem::talloc_array(char, 1024);
my_arr[..] = (char[*]){ [0..1023] = 0xA5 }[..];
}
}
fn void ensure_leak_check_works()
{
if (!(runtime::test_context.check_leaks)) return;
char[] my_arr = mem::alloc_array(char, 1024);
test::@check(((TrackingAllocator*)allocator::thread_allocator).has_leaks());
mem::free(my_arr);
test::@check(!((TrackingAllocator*)allocator::thread_allocator).has_leaks());
}