diff options
Diffstat (limited to 'tests/iii')
| -rw-r--r-- | tests/iii/default-return-errors/case.json | 10 | ||||
| -rw-r--r-- | tests/iii/default-return-errors/program.cps | 33 | ||||
| -rw-r--r-- | tests/iii/default-return-template/case.json | 5 | ||||
| -rw-r--r-- | tests/iii/default-return-template/program.cps | 5 | ||||
| -rw-r--r-- | tests/iii/multifile-default-return/case.json | 6 | ||||
| -rw-r--r-- | tests/iii/multifile-default-return/first.cps | 3 | ||||
| -rw-r--r-- | tests/iii/multifile-default-return/program.cps | 3 | ||||
| -rw-r--r-- | tests/iii/multifile-default-return/second.cps | 3 |
8 files changed, 68 insertions, 0 deletions
diff --git a/tests/iii/default-return-errors/case.json b/tests/iii/default-return-errors/case.json new file mode 100644 index 0000000..654bca5 --- /dev/null +++ b/tests/iii/default-return-errors/case.json @@ -0,0 +1,10 @@ +{ + "errors": [ + {"reason": "Duplicate DEFAULT return", "line": 4}, + {"reason": "DEFAULT requires a non-VOID OVERLOAD FUNCTION", "line": 7}, + {"reason": "DEFAULT requires a non-VOID OVERLOAD FUNCTION", "line": 10}, + {"reason": "No matching overload for Typed\\(\\) returning BOOLEAN", "line": 25}, + {"reason": "Ambiguous call to Ambiguous", "line": 26}, + {"reason": "Ambiguous call to Clash", "line": 33} + ] +} diff --git a/tests/iii/default-return-errors/program.cps b/tests/iii/default-return-errors/program.cps new file mode 100644 index 0000000..cd30994 --- /dev/null +++ b/tests/iii/default-return-errors/program.cps @@ -0,0 +1,33 @@ +OVERLOAD FUNCTION Duplicate(X : INTEGER) RETURNS DEFAULT INTEGER + RETURN 1 +ENDFUNCTION +OVERLOAD FUNCTION duplicate(X : INTEGER) RETURNS DEFAULT REAL + RETURN 2.0 +ENDFUNCTION +FUNCTION Plain() RETURNS DEFAULT INTEGER + RETURN 1 +ENDFUNCTION +OVERLOAD FUNCTION Empty() RETURNS DEFAULT VOID +ENDFUNCTION +OVERLOAD FUNCTION Ambiguous() RETURNS INTEGER + RETURN 1 +ENDFUNCTION +OVERLOAD FUNCTION Ambiguous() RETURNS REAL + RETURN 2.0 +ENDFUNCTION +OVERLOAD FUNCTION Typed() RETURNS DEFAULT INTEGER + RETURN 1 +ENDFUNCTION +OVERLOAD FUNCTION Typed() RETURNS REAL + RETURN 2.0 +ENDFUNCTION +DECLARE Flag : BOOLEAN +Flag <- Typed() +OUTPUT Ambiguous() +OVERLOAD FUNCTION Clash(A : STRING, B : CHAR) RETURNS DEFAULT INTEGER + RETURN 1 +ENDFUNCTION +OVERLOAD FUNCTION Clash(A : CHAR, B : STRING) RETURNS REAL + RETURN 2.0 +ENDFUNCTION +OUTPUT Clash("a", "b") diff --git a/tests/iii/default-return-template/case.json b/tests/iii/default-return-template/case.json new file mode 100644 index 0000000..6e43a53 --- /dev/null +++ b/tests/iii/default-return-template/case.json @@ -0,0 +1,5 @@ +{ + "errors": [ + {"reason": "DEFAULT return types are not supported in templates", "line": 2} + ] +} diff --git a/tests/iii/default-return-template/program.cps b/tests/iii/default-return-template/program.cps new file mode 100644 index 0000000..8f71900 --- /dev/null +++ b/tests/iii/default-return-template/program.cps @@ -0,0 +1,5 @@ +TEMPLATE <T> +OVERLOAD FUNCTION Pick(X : T) RETURNS DEFAULT INTEGER + RETURN 1 +ENDFUNCTION +OUTPUT 1 diff --git a/tests/iii/multifile-default-return/case.json b/tests/iii/multifile-default-return/case.json new file mode 100644 index 0000000..5679a0f --- /dev/null +++ b/tests/iii/multifile-default-return/case.json @@ -0,0 +1,6 @@ +{ + "sources": ["program.cps", "first.cps", "second.cps"], + "errors": [ + {"reason": "Duplicate DEFAULT return", "file": "second.cps", "line": 1} + ] +} diff --git a/tests/iii/multifile-default-return/first.cps b/tests/iii/multifile-default-return/first.cps new file mode 100644 index 0000000..a376dda --- /dev/null +++ b/tests/iii/multifile-default-return/first.cps @@ -0,0 +1,3 @@ +OVERLOAD FUNCTION Pick(X : INTEGER) RETURNS DEFAULT INTEGER + RETURN 1 +ENDFUNCTION diff --git a/tests/iii/multifile-default-return/program.cps b/tests/iii/multifile-default-return/program.cps new file mode 100644 index 0000000..15feac7 --- /dev/null +++ b/tests/iii/multifile-default-return/program.cps @@ -0,0 +1,3 @@ +INCLUDE "first.cps" +INCLUDE "second.cps" +OUTPUT 1 diff --git a/tests/iii/multifile-default-return/second.cps b/tests/iii/multifile-default-return/second.cps new file mode 100644 index 0000000..70b4667 --- /dev/null +++ b/tests/iii/multifile-default-return/second.cps @@ -0,0 +1,3 @@ +OVERLOAD FUNCTION Pick(X : INTEGER) RETURNS DEFAULT REAL + RETURN 2.0 +ENDFUNCTION |
