diff options
Diffstat (limited to 'tests/i')
| -rw-r--r-- | tests/i/input-targets/case.json | 1 | ||||
| -rw-r--r-- | tests/i/input-targets/expected.txt | 11 | ||||
| -rw-r--r-- | tests/i/input-targets/input.txt | 2 | ||||
| -rw-r--r-- | tests/i/input-targets/notes.md | 7 | ||||
| -rw-r--r-- | tests/i/input-targets/program.cps | 56 |
5 files changed, 77 insertions, 0 deletions
diff --git a/tests/i/input-targets/case.json b/tests/i/input-targets/case.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/i/input-targets/case.json @@ -0,0 +1 @@ +{} diff --git a/tests/i/input-targets/expected.txt b/tests/i/input-targets/expected.txt new file mode 100644 index 0000000..75640cd --- /dev/null +++ b/tests/i/input-targets/expected.txt @@ -0,0 +1,11 @@ +10:20:30:40 +80:Ada:TRUE:A +TRUE:-7 +60:70 +index evaluated +90 +[Fatal] line 45: Array index out of bounds +bounds caught +[Fatal] line 51: Dereference of an unset pointer +pointer caught +100 diff --git a/tests/i/input-targets/input.txt b/tests/i/input-targets/input.txt new file mode 100644 index 0000000..dc0af77 --- /dev/null +++ b/tests/i/input-targets/input.txt @@ -0,0 +1,2 @@ +10 20 30 +40 50 Ada 1 A 2.5 -7 60 70 80 90 100 diff --git a/tests/i/input-targets/notes.md b/tests/i/input-targets/notes.md new file mode 100644 index 0000000..dded40c --- /dev/null +++ b/tests/i/input-targets/notes.md @@ -0,0 +1,7 @@ +# INPUT targets + +Human review: pending. Expected output was independently traced by AI, not captured from cpsc. + +Basis: CIE guide p. 15 section 5.1 allows individual data-structure elements. Native C input, numeric BOOLEAN input, whitespace-delimited STRING input and exceptions follow project behavior. + +Trace: the loop stores 10, 20, 30; the grid receives 40. Student 2 receives 50, Ada, true, A, 2.5 and -7, then its score becomes 80 through P. The class fields receive 60 and 70. NextIndex prints once and selects Scores[1], which receives 90. Bounds and null-pointer failures occur before reading input, leaving 100 for the final valid input. 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] |
