aboutsummaryrefslogtreecommitdiff
path: root/tests/i/template-variadic/program.cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-21 06:04:52 +0000
committer_ov4 <ov4@ov4.org>2026-10-21 06:04:52 +0000
commit25ae363250e479701ed532c55c255e043c8240da (patch)
tree296977f6d6b1ba8ebfb5029fa0c7ea4235cbc9a5 /tests/i/template-variadic/program.cps
parentbfe020bfa91640e7a6f1a516dc752fa754249088 (diff)
feat(codegen): add variadic function templates
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/template-variadic/program.cps')
-rw-r--r--tests/i/template-variadic/program.cps37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/i/template-variadic/program.cps b/tests/i/template-variadic/program.cps
new file mode 100644
index 0000000..3127c89
--- /dev/null
+++ b/tests/i/template-variadic/program.cps
@@ -0,0 +1,37 @@
+OVERLOAD PROCEDURE PrintAll()
+ENDPROCEDURE
+
+TEMPLATE <T, Rest...>
+OVERLOAD PROCEDURE PrintAll(First : T, Others : Rest...)
+ OUTPUT First
+ CALL PrintAll(Others...)
+ENDPROCEDURE
+
+TEMPLATE <Types...>
+PROCEDURE Forward(Values : Types...)
+ CALL PrintAll<Types...>(Values...)
+ENDPROCEDURE
+
+TEMPLATE <T>
+OVERLOAD FUNCTION Pick(Value : T) RETURNS INTEGER
+ RETURN 10
+ENDFUNCTION
+
+TEMPLATE <T, Rest...>
+OVERLOAD FUNCTION Pick(First : T, Others : Rest...) RETURNS INTEGER
+ RETURN 20
+ENDFUNCTION
+
+OVERLOAD FUNCTION Pick(Value : INTEGER) RETURNS INTEGER
+ RETURN 30
+ENDFUNCTION
+
+CALL PrintAll(1, 2.5, 'c', "str")
+CALL PrintAll()
+CALL PrintAll<INTEGER>(1, 2.5)
+CALL Forward<INTEGER>(7, 3.5)
+CALL Forward()
+OUTPUT Pick(1)
+OUTPUT Pick(1.0)
+OUTPUT Pick(1, 2)
+OUTPUT Pick<INTEGER>(1)