diff options
Diffstat (limited to 'tests/main.c')
-rw-r--r-- | tests/main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/main.c b/tests/main.c index 3336c46..05725f7 100644 --- a/tests/main.c +++ b/tests/main.c @@ -131,6 +131,16 @@ static CHECK_RESULT int get_thread_count_env_var(int *thread_count) { return 0; } +static int print_extern() { + printf("hello from amalgam extern func, print_extern!\n"); + return 0; +} + +static int print_extern_num(i64 num) { + printf("hello from amalgam extern func, print_extern_num, value: %ld!\n", num); + return 0; +} + static void test_load(const char *filepath) { amal_compiler_options options; amal_program program; @@ -146,6 +156,16 @@ static void test_load(const char *filepath) { fprintf(stderr, "Failed to initialize amal program\n"); FAIL_TEST(full_path); } + + if(amal_program_add_extern_func(&program, create_buffer_view("print_extern", 12), print_extern, 0) != 0) { + fprintf(stderr, "Unexpected error (alloc failure)\n"); + FAIL_TEST(full_path); + } + if(amal_program_add_extern_func(&program, create_buffer_view("print_extern_num", 16), print_extern_num, sizeof(i64)) != 0) { + fprintf(stderr, "Unexpected error (alloc failure)\n"); + FAIL_TEST(full_path); + } + result = amal_compiler_load_file(&options, &program, filepath); if(result != AMAL_COMPILER_OK) { fprintf(stderr, "Failed to load file %s, result: %d\n", full_path, result); @@ -252,6 +272,8 @@ static void run_all_tests() { " ^\n"); test_load_error("tests/errors/no_main_func.amal", NULL); test_load_error("tests/errors/closure_duplicate_param_name.amal", "TODO: Add expected error here"); + test_load_error("tests/errors/extern_closure_one_return_value.amal", "TODO: Add expected error here"); + test_load_error("tests/errors/too_long_var_name.amal", "TODO: Add expected error here"); } /* TODO: Restrict variables in global scope to const */ |