aboutsummaryrefslogtreecommitdiff
path: root/tests/i/input-targets/program.cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 05:08:42 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 05:08:42 +0000
commita6b8afcfb61e1d321405fe8713beaec2aa6320a2 (patch)
treea621462bd6f858d1e78495e8c850a2e7321f4809 /tests/i/input-targets/program.cps
parent5c3d4d059ae70ea72b52e89940746d61c1d962db (diff)
feat(input): support array elements and member targets
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/input-targets/program.cps')
-rw-r--r--tests/i/input-targets/program.cps56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/i/input-targets/program.cps b/tests/i/input-targets/program.cps
new file mode 100644
index 0000000..d7628d3
--- /dev/null
+++ b/tests/i/input-targets/program.cps
@@ -0,0 +1,56 @@
+TYPE Student
+ DECLARE Score : INTEGER
+ DECLARE Name : STRING
+ DECLARE Passed : BOOLEAN
+ DECLARE Grade : CHAR
+ DECLARE Average : REAL
+ DECLARE Native : C_INT
+ENDTYPE
+CLASS Box
+ Value : INTEGER
+ Details : Student
+ENDCLASS
+TYPE StudentPtr = ^Student
+DECLARE Scores : ARRAY[1:3] OF INTEGER
+DECLARE Grid : ARRAY[-1:0,2:3] OF INTEGER
+DECLARE Students : ARRAY[1:2] OF Student
+DECLARE Item : Box
+DECLARE P : StudentPtr
+DECLARE j : INTEGER
+FOR j <- 1 TO 3
+ INPUT Scores[j]
+NEXT j
+INPUT Grid[-1,3]
+INPUT Students[2].Score
+INPUT Students[2].Name
+INPUT Students[2].Passed
+INPUT Students[2].Grade
+INPUT Students[2].Average
+INPUT Students[2].Native
+INPUT Item.Value
+INPUT Item.Details.Score
+P <- ^Students[2]
+INPUT P^.Score
+OUTPUT Scores[1], ":", Scores[2], ":", Scores[3], ":", Grid[-1,3]
+OUTPUT Students[2].Score, ":", Students[2].Name, ":", Students[2].Passed, ":", Students[2].Grade
+OUTPUT Students[2].Average = 2.5, ":", Students[2].Native
+OUTPUT Item.Value, ":", Item.Details.Score
+FUNCTION NextIndex() RETURNS INTEGER
+ OUTPUT "index evaluated"
+ RETURN 1
+ENDFUNCTION
+INPUT Scores[NextIndex()]
+OUTPUT Scores[1]
+TRY
+ INPUT Scores[4]
+CATCH
+ OUTPUT "bounds caught"
+ENDTRY
+DECLARE Unset : StudentPtr
+TRY
+ INPUT Unset^.Score
+CATCH
+ OUTPUT "pointer caught"
+ENDTRY
+INPUT Scores[1]
+OUTPUT Scores[1]