diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i/multifile-extern/case.json | 6 | ||||
| -rw-r--r-- | tests/i/multifile-extern/expected.txt | 2 | ||||
| -rw-r--r-- | tests/i/multifile-extern/lib.cps | 6 | ||||
| -rw-r--r-- | tests/i/multifile-extern/notes.md | 7 | ||||
| -rw-r--r-- | tests/i/multifile-extern/program.cps | 6 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/case.json | 13 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/lib.cps | 3 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/notes.md | 5 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/program.cps | 4 |
9 files changed, 52 insertions, 0 deletions
diff --git a/tests/i/multifile-extern/case.json b/tests/i/multifile-extern/case.json new file mode 100644 index 0000000..032ec6a --- /dev/null +++ b/tests/i/multifile-extern/case.json @@ -0,0 +1,6 @@ +{ + "sources": [ + "program.cps", + "lib.cps" + ] +} diff --git a/tests/i/multifile-extern/expected.txt b/tests/i/multifile-extern/expected.txt new file mode 100644 index 0000000..19d70eb --- /dev/null +++ b/tests/i/multifile-extern/expected.txt @@ -0,0 +1,2 @@ +3 +8 diff --git a/tests/i/multifile-extern/lib.cps b/tests/i/multifile-extern/lib.cps new file mode 100644 index 0000000..52ccf1f --- /dev/null +++ b/tests/i/multifile-extern/lib.cps @@ -0,0 +1,6 @@ +INCLUDE_OBJ "__libc" +TYPE NativeInt = C_TYPE("int") +EXTERN "C" EXTERN_FUNCTION abs(NativeInt) RETURNS C_INT +FUNCTION Twice(N : C_INT) RETURNS C_INT + RETURN abs(N) + abs(N) +ENDFUNCTION diff --git a/tests/i/multifile-extern/notes.md b/tests/i/multifile-extern/notes.md new file mode 100644 index 0000000..f326c82 --- /dev/null +++ b/tests/i/multifile-extern/notes.md @@ -0,0 +1,7 @@ +# multifile-extern + +Human review: pending. Expected output was independently traced by AI, not captured from cpsc. + +Basis: compiler extension; identical EXTERN declarations may repeat across files, as C declarations may. + +Trace: abs(-3)=3. Twice(-4) returns abs(-4)+abs(-4)=8. diff --git a/tests/i/multifile-extern/program.cps b/tests/i/multifile-extern/program.cps new file mode 100644 index 0000000..7a0cd2d --- /dev/null +++ b/tests/i/multifile-extern/program.cps @@ -0,0 +1,6 @@ +// Both files declare the same C function; aliases of int are interchangeable. +INCLUDE "lib.cps" +INCLUDE_OBJ "__libc" +EXTERN "C" EXTERN_FUNCTION abs(C_INT) RETURNS C_INT +OUTPUT abs((C_INT)-3) +OUTPUT Twice((C_INT)-4) diff --git a/tests/iii/multifile-extern-conflict/case.json b/tests/iii/multifile-extern-conflict/case.json new file mode 100644 index 0000000..1eb3f1d --- /dev/null +++ b/tests/iii/multifile-extern-conflict/case.json @@ -0,0 +1,13 @@ +{ + "sources": [ + "program.cps", + "lib.cps" + ], + "errors": [ + { + "reason": "Conflicting EXTERN declarations of abs", + "line": 3, + "file": "lib.cps" + } + ] +} diff --git a/tests/iii/multifile-extern-conflict/lib.cps b/tests/iii/multifile-extern-conflict/lib.cps new file mode 100644 index 0000000..2c15253 --- /dev/null +++ b/tests/iii/multifile-extern-conflict/lib.cps @@ -0,0 +1,3 @@ +// The result type differs from program.cps. +INCLUDE_OBJ "__libc" +EXTERN "C" EXTERN_FUNCTION abs(C_INT) RETURNS C_DOUBLE diff --git a/tests/iii/multifile-extern-conflict/notes.md b/tests/iii/multifile-extern-conflict/notes.md new file mode 100644 index 0000000..6ac25b7 --- /dev/null +++ b/tests/iii/multifile-extern-conflict/notes.md @@ -0,0 +1,5 @@ +# multifile-extern-conflict + +Compiler extension: repeated EXTERN declarations must have identical signatures; lib.cps changes the result type. + +Require exit 1 and the cause on the second declaration. diff --git a/tests/iii/multifile-extern-conflict/program.cps b/tests/iii/multifile-extern-conflict/program.cps new file mode 100644 index 0000000..058cd5e --- /dev/null +++ b/tests/iii/multifile-extern-conflict/program.cps @@ -0,0 +1,4 @@ +INCLUDE "lib.cps" +INCLUDE_OBJ "__libc" +EXTERN "C" EXTERN_FUNCTION abs(C_INT) RETURNS C_INT +OUTPUT abs((C_INT)-3) |
