diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i/class-delete/case.json | 1 | ||||
| -rw-r--r-- | tests/i/class-delete/expected.txt | 10 | ||||
| -rw-r--r-- | tests/i/class-delete/notes.md | 5 | ||||
| -rw-r--r-- | tests/i/class-delete/program.cps | 35 | ||||
| -rw-r--r-- | tests/iii/class-delete-type-error/case.json | 8 | ||||
| -rw-r--r-- | tests/iii/class-delete-type-error/program.cps | 2 |
6 files changed, 61 insertions, 0 deletions
diff --git a/tests/i/class-delete/case.json b/tests/i/class-delete/case.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/i/class-delete/case.json @@ -0,0 +1 @@ +{} diff --git a/tests/i/class-delete/expected.txt b/tests/i/class-delete/expected.txt new file mode 100644 index 0000000..85c4753 --- /dev/null +++ b/tests/i/class-delete/expected.txt @@ -0,0 +1,10 @@ +pair +pair +pair +leaf:2 +leaf:1 +[Fatal] line 24: Invalid memory address (not an active allocation) +double caught +[Fatal] line 30: Invalid memory address (not an active allocation) +stack caught +leaf:2 diff --git a/tests/i/class-delete/notes.md b/tests/i/class-delete/notes.md new file mode 100644 index 0000000..c4e2638 --- /dev/null +++ b/tests/i/class-delete/notes.md @@ -0,0 +1,5 @@ +# Keyword DELETE + +Human review: pending. Expected output was independently traced by AI. + +Explicit calls print only the outer method. Keyword DELETE prints outer, right, left. Invalid stack and stale heap addresses throw before any method runs. The array element uses an ordinary explicit method call. diff --git a/tests/i/class-delete/program.cps b/tests/i/class-delete/program.cps new file mode 100644 index 0000000..492c032 --- /dev/null +++ b/tests/i/class-delete/program.cps @@ -0,0 +1,35 @@ +CLASS Leaf + Value : INTEGER + PROCEDURE DELETE() + OUTPUT "leaf:", Value + ENDPROCEDURE +ENDCLASS +CLASS Pair + Left : Leaf + Right : Leaf + PROCEDURE NEW() + Left.Value <- 1 + Right.Value <- 2 + ENDPROCEDURE + PROCEDURE DELETE() + OUTPUT "pair" + ENDPROCEDURE +ENDCLASS +DECLARE Obj : Pair +Obj <- NEW Pair() +Obj.DELETE() +CALL Obj.DELETE() +DELETE Obj +TRY + DELETE Obj +CATCH + OUTPUT "double caught" +ENDTRY +DECLARE Stack : Pair +TRY + DELETE Stack +CATCH + OUTPUT "stack caught" +ENDTRY +DECLARE Items : ARRAY[1:2] OF Pair +Items[2].Right.DELETE() diff --git a/tests/iii/class-delete-type-error/case.json b/tests/iii/class-delete-type-error/case.json new file mode 100644 index 0000000..efbbafb --- /dev/null +++ b/tests/iii/class-delete-type-error/case.json @@ -0,0 +1,8 @@ +{ + "errors": [ + { + "reason": "DELETE requires a class object", + "line": 2 + } + ] +} diff --git a/tests/iii/class-delete-type-error/program.cps b/tests/iii/class-delete-type-error/program.cps new file mode 100644 index 0000000..d468f19 --- /dev/null +++ b/tests/iii/class-delete-type-error/program.cps @@ -0,0 +1,2 @@ +DECLARE N : INTEGER +DELETE N |
