aboutsummaryrefslogtreecommitdiff
path: root/tests/i/class-delete/program.cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 08:32:43 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 08:32:43 +0000
commit59e3c50bcd58130e81e1f57b21d6e57b4d4aba6d (patch)
treec5f6c5b1bd367feadca0c2e7d0f47c8dedb91b20 /tests/i/class-delete/program.cps
parente847e4c53cf21fcb96f7ed7765e305a7ec8e6c19 (diff)
feat(classes): destroy and release heap objects with DELETE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/class-delete/program.cps')
-rw-r--r--tests/i/class-delete/program.cps35
1 files changed, 35 insertions, 0 deletions
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()