From 8b720543f538862796fec0ff6b7ea12cb140bf0f Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Sun, 25 Jan 2026 14:38:28 +0000 Subject: Fix for #90 --- tests/functions/test_raw_func_ptr.zc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/functions/test_raw_func_ptr.zc (limited to 'tests/functions') diff --git a/tests/functions/test_raw_func_ptr.zc b/tests/functions/test_raw_func_ptr.zc new file mode 100644 index 0000000..16ec7df --- /dev/null +++ b/tests/functions/test_raw_func_ptr.zc @@ -0,0 +1,27 @@ + +fn print_msg(msg: char*) { + puts(msg); +} + +fn run_callback(cb: fn*(char*), arg: char*) { + cb(arg); +} + +fn get_printer() -> fn*(char*) { + return print_msg; +} + +test "raw_func_ptr_basic" { + run_callback(print_msg, "Hello Raw Ptr"); +} + +test "raw_func_ptr_return_explicit" { + var p: fn*(char*) = get_printer(); + p("Returned Ptr Explicit works"); +} + +test "fn_ptr_ptr" { + var p: fn*(char*) = print_msg; + var pp: fn**(char*) = &p; + (*pp)("Double Pointer works"); +} -- cgit v1.2.3