summaryrefslogtreecommitdiff
path: root/tests/interop
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-14 23:59:54 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-14 23:59:54 +0000
commitdcfdc053cb5f9fb4d5eac0a2233c75126b7a8188 (patch)
treef34f30b382fa22d6fd0af46875a5b4b26d00feff /tests/interop
parenta918df69269a39ef7350a645b5db025d66ecb18a (diff)
Added some of the tests.
Diffstat (limited to 'tests/interop')
-rw-r--r--tests/interop/test_c_import.zc26
-rw-r--r--tests/interop/test_c_macros.zc22
2 files changed, 48 insertions, 0 deletions
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
+}