diff options
Diffstat (limited to 'tests/i/caught-errors')
| -rw-r--r-- | tests/i/caught-errors/case.json | 3 | ||||
| -rw-r--r-- | tests/i/caught-errors/expected.txt | 10 | ||||
| -rw-r--r-- | tests/i/caught-errors/notes.md | 7 | ||||
| -rw-r--r-- | tests/i/caught-errors/program.cps | 31 |
4 files changed, 51 insertions, 0 deletions
diff --git a/tests/i/caught-errors/case.json b/tests/i/caught-errors/case.json new file mode 100644 index 0000000..1f18635 --- /dev/null +++ b/tests/i/caught-errors/case.json @@ -0,0 +1,3 @@ +{ + "exit_code": 0 +} diff --git a/tests/i/caught-errors/expected.txt b/tests/i/caught-errors/expected.txt new file mode 100644 index 0000000..ae32ca6 --- /dev/null +++ b/tests/i/caught-errors/expected.txt @@ -0,0 +1,10 @@ +[Fatal] line 7: Division by zero +division caught +[Fatal] line 12: Array index out of bounds +bounds caught +[Fatal] line 17: Dereference of an unset pointer +pointer caught +[Fatal] line 22: File 'closed.txt' is not open +file caught +throw caught +alive diff --git a/tests/i/caught-errors/notes.md b/tests/i/caught-errors/notes.md new file mode 100644 index 0000000..9535a55 --- /dev/null +++ b/tests/i/caught-errors/notes.md @@ -0,0 +1,7 @@ +# caught-errors + +Human review: pending. Expected output was independently traced by AI, not captured from cpsc. + +Basis: Project TRY and runtime-check contract; diagnostics precede catch execution on stdout. + +Trace: Each failed access transfers to its CATCH, so no attempted value is printed. Source lines 7,12,17,22 identify the operations. Bare THROW has no own diagnostic; execution reaches alive. diff --git a/tests/i/caught-errors/program.cps b/tests/i/caught-errors/program.cps new file mode 100644 index 0000000..919696b --- /dev/null +++ b/tests/i/caught-errors/program.cps @@ -0,0 +1,31 @@ +DECLARE X : INTEGER +DECLARE Values : ARRAY[1:1] OF INTEGER +TYPE IntPtr = ^INTEGER +DECLARE P : IntPtr +X <- 0 +TRY + OUTPUT 4 DIV X +CATCH + OUTPUT "division caught" +ENDTRY +TRY + OUTPUT Values[2] +CATCH + OUTPUT "bounds caught" +ENDTRY +TRY + OUTPUT P^ +CATCH + OUTPUT "pointer caught" +ENDTRY +TRY + CLOSEFILE "closed.txt" +CATCH + OUTPUT "file caught" +ENDTRY +TRY + THROW +CATCH + OUTPUT "throw caught" +ENDTRY +OUTPUT "alive" |
