From c811a743a1528db1d05970e1aa14162ef7c70b75 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 21 Sep 2019 13:59:39 +0200 Subject: Implement vararg, verify arguments to parameters --- tests/bytecode.amal | 30 ++---------------------------- tests/errors/return_borrow.amal | 1 + tests/main.c | 4 ++++ 3 files changed, 7 insertions(+), 28 deletions(-) create mode 100644 tests/errors/return_borrow.amal (limited to 'tests') diff --git a/tests/bytecode.amal b/tests/bytecode.amal index 6941bc8..d27a240 100644 --- a/tests/bytecode.amal +++ b/tests/bytecode.amal @@ -1,31 +1,5 @@ -/* -extern const print_extern: fn() i32; -extern const print_extern_num: fn(num: i32) i32; +extern const printf: fn(fmt: ?*c_char, ...) c_int; -const print = fn() i32 { - return 0; -} - -const main = fn { - var value = 23; - value = 34; - const value2: i64 = 54; - const value3 = 2 + 5 - 1 * 10 / 2; - const str_value = "hello, world"; - print(); - if value2 == 54 - const result = print_num(1337); -} - -const print_num = fn(num: i32) i32 { - print_extern(); - print_extern_num(num); - print_extern_num(8080); - return num; -} -*/ - -const io = @import("../std/io.amal"); const main = fn { - io.print(); + printf("hello, world!\n"); } diff --git a/tests/errors/return_borrow.amal b/tests/errors/return_borrow.amal new file mode 100644 index 0000000..ed1a043 --- /dev/null +++ b/tests/errors/return_borrow.amal @@ -0,0 +1 @@ +const func = fn() *str {} \ No newline at end of file diff --git a/tests/main.c b/tests/main.c index 019f8d9..0b3a744 100644 --- a/tests/main.c +++ b/tests/main.c @@ -251,6 +251,10 @@ static void test_load(const char *filepath) { fprintf(stderr, "Unexpected error (alloc failure)\n"); FAIL_TEST_CLEANUP(full_path); } + if(amal_program_register_extern_func(&program, create_buffer_view_auto("printf"), printf, sizeof(const char*)) != 0) { + fprintf(stderr, "Unexpected error (alloc failure)\n"); + FAIL_TEST_CLEANUP(full_path); + } result = amal_compiler_load_file(&options, &program, filepath); if(result != AMAL_COMPILER_OK) { -- cgit v1.2.3