From dcfdc053cb5f9fb4d5eac0a2233c75126b7a8188 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Wed, 14 Jan 2026 23:59:54 +0000 Subject: Added some of the tests. --- tests/interop/test_c_import.zc | 26 ++++++++++++++++++++++++++ tests/interop/test_c_macros.zc | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/interop/test_c_import.zc create mode 100644 tests/interop/test_c_macros.zc (limited to 'tests/interop') diff --git a/tests/interop/test_c_import.zc b/tests/interop/test_c_import.zc new file mode 100644 index 0000000..ed95bc1 --- /dev/null +++ b/tests/interop/test_c_import.zc @@ -0,0 +1,26 @@ + +import "math.h" as m; + +test "test_c_import" { + var x = m::sin(0.0); + + if x == 0.0 { + println "Success: m::sin(0.0) == 0.0"; + } else { + println "Failure: Unexpected result"; + exit(1); + } + } +} + +extern fn abs(x: int) -> int; + +test "test_interop_abs" { + var x = -10; + var y = abs(x); + if (y == 10) println "Abs works"; + else { + println "Abs failed"; + exit(1); + } +} diff --git a/tests/interop/test_c_macros.zc b/tests/interop/test_c_macros.zc new file mode 100644 index 0000000..0b1fc64 --- /dev/null +++ b/tests/interop/test_c_macros.zc @@ -0,0 +1,22 @@ + +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define DEBUG_MODE 1 + +test "test_c_macros" { + var x = MAX(10, 20); + + if x == 20 { + println "MAX macro worked"; + } else { + println "MAX macro failed"; + exit(1); + } + + #ifdef DEBUG_MODE + println "Debug mode active"; + #endif + + #ifndef INVALID_MACRO + println "Conditionals working"; + #endif +} -- cgit v1.2.3