aboutsummaryrefslogtreecommitdiff
path: root/tests/i/template-explicit-args/program.cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-21 06:00:55 +0000
committer_ov4 <ov4@ov4.org>2026-10-21 06:00:55 +0000
commitbfe020bfa91640e7a6f1a516dc752fa754249088 (patch)
treefd82055133f45fdeaacddd4e62b210f4b63e0c03 /tests/i/template-explicit-args/program.cps
parentc56877035d6600b463a9cbf0e339f7548c0b46fd (diff)
feat(codegen): support explicit template arguments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/template-explicit-args/program.cps')
-rw-r--r--tests/i/template-explicit-args/program.cps47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/i/template-explicit-args/program.cps b/tests/i/template-explicit-args/program.cps
new file mode 100644
index 0000000..123bda6
--- /dev/null
+++ b/tests/i/template-explicit-args/program.cps
@@ -0,0 +1,47 @@
+TEMPLATE <T>
+FUNCTION Max(A : T, B : T) RETURNS T
+ IF A > B THEN
+ RETURN A
+ ENDIF
+ RETURN B
+ENDFUNCTION
+
+TEMPLATE <A, B>
+FUNCTION Second(First : A, Last : B) RETURNS B
+ RETURN Last
+ENDFUNCTION
+
+TEMPLATE <T>
+FUNCTION Zero() RETURNS T
+ RETURN (T)0
+ENDFUNCTION
+
+TEMPLATE <T>
+PROCEDURE Print(Value : T)
+ OUTPUT Value
+ENDPROCEDURE
+
+TEMPLATE <T>
+FUNCTION Echo(Value : T) RETURNS T
+ RETURN Value
+ENDFUNCTION
+
+TEMPLATE <T>
+OVERLOAD FUNCTION Pick(Value : T) RETURNS INTEGER
+ RETURN 100
+ENDFUNCTION
+OVERLOAD FUNCTION Pick(Value : INTEGER) RETURNS INTEGER
+ RETURN 200
+ENDFUNCTION
+
+OUTPUT Max<REAL>(1.5, 2.0)
+OUTPUT Max<INTEGER>(Max<INTEGER>(1, 2), 3)
+OUTPUT Second<INTEGER>(7, "tail")
+OUTPUT Zero<REAL>()
+CALL Print<REAL>(2.5)
+Print<INTEGER>(9)
+OUTPUT Pick(7)
+OUTPUT Pick<INTEGER>(7)
+OUTPUT (STRING)Echo<STRING>("chain").C_STR()
+CALL Echo<STRING>("discarded")
+Echo<STRING>("also discarded")