Fix of #862 where enums declarations where not regenerated. Updated @pool implementation.

This commit is contained in:
Christoffer Lerno
2023-07-18 22:28:43 +02:00
committed by Christoffer Lerno
parent 491c5ceec5
commit 4dcfb7a675
10 changed files with 164 additions and 116 deletions

View File

@@ -0,0 +1,68 @@
module test;
fn String add(String s, Allocator* a, int x)
{
if (x < 0) return s.copy(a);
String tmp;
@pool(a)
{
tmp = "foo".tconcat(s);
tmp = add(tmp, a, x - 1);
};
ulong* y = malloc(ulong, .using = mem::temp());
*y = 0xAAAA_AAAA_AAAA_AAAA;
return tmp.concat("a", .using = a);
}
fn String breakit(String s, Allocator* a)
{
@pool(a)
{
return inner2("foo".concat(s, mem::temp()), a);
};
}
fn String inner2(String s, Allocator* a)
{
@pool(a)
{
ulong* z1 = tmalloc(ulong);
*z1 = 0xAAAA_AAAA_AAAA_AAAA;
String y = inner3(s, a);
ulong* z = tmalloc(ulong);
*z = 0xAAAA_AAAA_AAAA_AAAA;
return y;
};
}
fn String inner3(String s, Allocator* a)
{
@pool(a)
{
ulong* z1 = tmalloc(ulong);
*z1 = 0xAAAA_AAAA_AAAA_AAAA;
String y = inner4(s, a);
ulong* z = tmalloc(ulong);
*z = 0xAAAA_AAAA_AAAA_AAAA;
return y;
};
}
fn String inner4(String s, Allocator* a)
{
@pool(a)
{
String y = s.concat("xy**********", mem::temp()).copy(a);
return y;
};
}
fn void! test_temp_allocator() @test
{
assert("foofoofoofoofoofooabcaaaaaa" == add("abc", mem::temp(), 5), "was %s", add("abc", mem::temp(), 5));
}
fn void! test_temp_allocator2() @test
{
assert("fooxyz0123456789xy**********" == breakit("xyz0123456789", mem::temp()));
}