mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix of #862 where enums declarations where not regenerated. Updated @pool implementation.
This commit is contained in:
committed by
Christoffer Lerno
parent
491c5ceec5
commit
4dcfb7a675
68
test/unit/stdlib/mem/temp_mem.c3
Normal file
68
test/unit/stdlib/mem/temp_mem.c3
Normal 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()));
|
||||
}
|
||||
Reference in New Issue
Block a user