From 5c00b8cd03cbfc516cce92229f3f4974d7549c24 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 16 Oct 2026 20:53:52 +0800 Subject: test(compiler): cover fixed CIE behavior and runtime boundaries Record independently traced outputs with pending human review. Keep standard syntax and naming conflicts as real failures. Co-Authored-By: Claude Fable 5.1 --- tests/i/caught-errors/case.json | 3 +++ tests/i/caught-errors/expected.txt | 10 ++++++++++ tests/i/caught-errors/notes.md | 7 +++++++ tests/i/caught-errors/program.cps | 31 +++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/i/caught-errors/case.json create mode 100644 tests/i/caught-errors/expected.txt create mode 100644 tests/i/caught-errors/notes.md create mode 100644 tests/i/caught-errors/program.cps (limited to 'tests/i/caught-errors') 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" -- cgit v1.3.1-4-g156e