aboutsummaryrefslogtreecommitdiff
path: root/tests/iii/template-header-errors
diff options
context:
space:
mode:
Diffstat (limited to 'tests/iii/template-header-errors')
-rw-r--r--tests/iii/template-header-errors/case.json36
-rw-r--r--tests/iii/template-header-errors/program.cps39
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/iii/template-header-errors/case.json b/tests/iii/template-header-errors/case.json
new file mode 100644
index 0000000..f74cc0d
--- /dev/null
+++ b/tests/iii/template-header-errors/case.json
@@ -0,0 +1,36 @@
+{
+ "errors": [
+ {
+ "reason": "Duplicate template parameter",
+ "line": 1
+ },
+ {
+ "reason": "template parameter pack must be last",
+ "line": 6
+ },
+ {
+ "reason": "only one parameter pack",
+ "line": 10
+ },
+ {
+ "reason": "TEMPLATE cannot prefix TYPE",
+ "line": 14
+ },
+ {
+ "reason": "Operator templates are not supported",
+ "line": 17
+ },
+ {
+ "reason": "TEMPLATE declarations are only allowed at top level",
+ "line": 23
+ },
+ {
+ "reason": "TEMPLATE declarations are only allowed at top level",
+ "line": 30
+ },
+ {
+ "reason": "Expected '<' after TEMPLATE",
+ "line": 35
+ }
+ ]
+}
diff --git a/tests/iii/template-header-errors/program.cps b/tests/iii/template-header-errors/program.cps
new file mode 100644
index 0000000..73c34a2
--- /dev/null
+++ b/tests/iii/template-header-errors/program.cps
@@ -0,0 +1,39 @@
+TEMPLATE <T, t>
+FUNCTION Duplicate(Value : T) RETURNS T
+ RETURN Value
+ENDFUNCTION
+
+TEMPLATE <Rest..., T>
+PROCEDURE NotLast()
+ENDPROCEDURE
+
+TEMPLATE <A..., B...>
+PROCEDURE TwoPacks()
+ENDPROCEDURE
+
+TEMPLATE <T>
+TYPE Alias = ^T
+
+TEMPLATE <T>
+OVERLOAD FUNCTION OPERATOR+(Value : T) RETURNS T
+ RETURN Value
+ENDFUNCTION
+
+IF TRUE THEN
+ TEMPLATE <T>
+ PROCEDURE Nested(Value : T)
+ OUTPUT 99
+ ENDPROCEDURE
+ENDIF
+
+CLASS Outer
+ TEMPLATE <T>
+ PROCEDURE Member(Value : T)
+ ENDPROCEDURE
+ENDCLASS
+
+TEMPLATE <>
+PROCEDURE Empty()
+ENDPROCEDURE
+
+OUTPUT 0