aboutsummaryrefslogtreecommitdiff
path: root/tests/i/class-constructors/program.cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 06:52:23 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 06:52:23 +0000
commit39661855c0816ac248be437704c76f58359cb5f0 (patch)
tree202b014805e40208e3adb861f4a97d31770f13e6 /tests/i/class-constructors/program.cps
parentc89477d615fb0ce4d89786ef848ffe6aca1da088 (diff)
feat(classes): construct declared objects and nested fields and arrays
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/class-constructors/program.cps')
-rw-r--r--tests/i/class-constructors/program.cps42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/i/class-constructors/program.cps b/tests/i/class-constructors/program.cps
new file mode 100644
index 0000000..2b85b4d
--- /dev/null
+++ b/tests/i/class-constructors/program.cps
@@ -0,0 +1,42 @@
+CLASS Leaf
+ Value : INTEGER
+ PROCEDURE New()
+ OUTPUT "leaf:", Value
+ Value <- 3
+ ENDPROCEDURE
+ENDCLASS
+CLASS Pair
+ First : Leaf
+ Second : Leaf
+ PROCEDURE NEW()
+ OUTPUT "pair:", First.Value + Second.Value
+ ENDPROCEDURE
+ENDCLASS
+TYPE Wrapped
+ DECLARE Item : Pair
+ENDTYPE
+CLASS Named
+ Text : STRING
+ PROCEDURE NEW(Name : STRING)
+ Text <- Name
+ ENDPROCEDURE
+ENDCLASS
+CLASS Plain
+ Value : INTEGER
+ENDCLASS
+DECLARE A : Leaf
+DECLARE B : Leaf()
+DECLARE N : Named("name")
+OUTPUT N.Text
+DECLARE P : Plain()
+OUTPUT P.Value
+DECLARE Items : ARRAY[-1:0, 2:3] OF Leaf
+OUTPUT Items[-1,2].Value, ",", Items[0,3].Value
+DECLARE W : Wrapped
+OUTPUT W.Item.First.Value, ",", W.Item.Second.Value
+DECLARE Index : INTEGER
+FOR Index <- 1 TO 2
+ DECLARE Local : Leaf
+ OUTPUT Local.Value
+ Local.Value <- 99
+NEXT Index