diff --git a/tests/arrays.c b/tests/arrays.c new file mode 100644 index 0000000..e9aed4f --- /dev/null +++ b/tests/arrays.c @@ -0,0 +1,47 @@ +#include "libsuicmez/libsuicmez.h" +#include +#include +#include +#include + +void* gc_alloc(const TypeInfo* type, size_t size); +void gc_init(void); +void gc_shutdown(void); + +// Helper for allocating arrays +static void* suic_alloc_array(const TypeInfo* type, size_t elem_size, size_t len, void* init_data) { + void* ptr = gc_alloc(type, elem_size * len); + if (init_data) memcpy(ptr, init_data, elem_size * len); + return ptr; +} + +// Helper for allocating structs +static void* suic_alloc_struct(const TypeInfo* type, size_t size, void* init_data) { + void* ptr = gc_alloc(type, size); + if (init_data) memcpy(ptr, init_data, size); + return ptr; +} + + + + +int suic_main(void); + + +int suic_main(void) { + int* arr = suic_alloc_array(NULL, sizeof(int), 4, (int[]){1, 2, 3, 4}); + int x = arr[0]; + return x; +} + +int main(int argc, char* argv[]) { + // Initialize GC + gc_init(); + // init globals + // init event loop + int result = suic_main(); + // Shutdown GC + gc_shutdown(); + return result; +} + diff --git a/tests/arrays.o b/tests/arrays.o new file mode 100755 index 0000000..f33660a Binary files /dev/null and b/tests/arrays.o differ diff --git a/tests/arrays.sui b/tests/arrays.sui index 248cfb4..85d4c46 100644 --- a/tests/arrays.sui +++ b/tests/arrays.sui @@ -1,7 +1,7 @@ # Array test -fn main(args: [string]) -> int do +fn main() -> int do let arr = [1, 2, 3, 4]; - let empty = []; + # let empty = []; let x = arr[0]; x end