summaryrefslogtreecommitdiff
path: root/tests/features/test_comptime_suite.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/features/test_comptime_suite.zc')
-rw-r--r--tests/features/test_comptime_suite.zc29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/features/test_comptime_suite.zc b/tests/features/test_comptime_suite.zc
new file mode 100644
index 0000000..b8127ec
--- /dev/null
+++ b/tests/features/test_comptime_suite.zc
@@ -0,0 +1,29 @@
+
+comptime {
+ printf("fn generated_func() {\n");
+ printf(" println \" I was generated at compile time!\";\n");
+ printf("}\n");
+}
+
+@comptime
+fn double_ct(x: int) -> int {
+ return x * 2;
+}
+
+test "test_comptime_block" {
+ println "Running Comptime Test...";
+ generated_func();
+ println "Comptime Test Complete.";
+}
+
+test "test_comptime_attr" {
+ var x = double_ct(21);
+ assert(x == 42, "Comptime function failed");
+ println "Comptime function called successfully";
+}
+
+test "test_comptime_fn" {
+ comptime {
+ println "println \"Hello from comptime fn!\";";
+ }
+}