diff options
Diffstat (limited to 'tests/i')
| -rw-r--r-- | tests/i/class-default-public/notes.md | 2 | ||||
| -rw-r--r-- | tests/i/identifier-case/notes.md | 2 | ||||
| -rw-r--r-- | tests/i/identifier-domains/case.json | 3 | ||||
| -rw-r--r-- | tests/i/identifier-domains/expected.txt | 7 | ||||
| -rw-r--r-- | tests/i/identifier-domains/notes.md | 5 | ||||
| -rw-r--r-- | tests/i/identifier-domains/program.cps | 43 | ||||
| -rw-r--r-- | tests/i/integer-literal-contexts/case.json | 3 | ||||
| -rw-r--r-- | tests/i/integer-literal-contexts/expected.txt | 3 | ||||
| -rw-r--r-- | tests/i/integer-literal-contexts/notes.md | 5 | ||||
| -rw-r--r-- | tests/i/integer-literal-contexts/program.cps | 10 | ||||
| -rw-r--r-- | tests/i/loops/notes.md | 2 | ||||
| -rw-r--r-- | tests/i/loops/program.cps | 4 | ||||
| -rw-r--r-- | tests/i/text-files/notes.md | 2 | ||||
| -rw-r--r-- | tests/i/text-files/program.cps | 4 |
14 files changed, 87 insertions, 8 deletions
diff --git a/tests/i/class-default-public/notes.md b/tests/i/class-default-public/notes.md index 1f5c869..db762db 100644 --- a/tests/i/class-default-public/notes.md +++ b/tests/i/class-default-public/notes.md @@ -2,6 +2,6 @@ Human review: pending. Expected output was independently traced by AI, not captured from cpsc. -Basis: CIE p. 28: methods and properties are public unless otherwise stated. This conflicts with the current explicit-access requirement. +Basis: CIE p. 28: methods and properties are public unless otherwise stated. The compiler accepts omitted access as public. Trace: Value has default public access. Assigning and reading it must yield 7. A compile rejection is a failure, not an accepted alternative. diff --git a/tests/i/identifier-case/notes.md b/tests/i/identifier-case/notes.md index ac8c200..ac6e5e8 100644 --- a/tests/i/identifier-case/notes.md +++ b/tests/i/identifier-case/notes.md @@ -2,6 +2,6 @@ Human review: pending. Expected output was independently traced by AI, not captured from cpsc. -Basis: CIE p. 7: identifiers should be considered case insensitive. Current symbol lookup is case sensitive. +Basis: CIE p. 7: identifiers should be considered case insensitive. Symbol lookup must resolve both spellings to the same declaration. Trace: Counter and counter denote the same declared variable; the read yields 7. diff --git a/tests/i/identifier-domains/case.json b/tests/i/identifier-domains/case.json new file mode 100644 index 0000000..1f18635 --- /dev/null +++ b/tests/i/identifier-domains/case.json @@ -0,0 +1,3 @@ +{ + "exit_code": 0 +} diff --git a/tests/i/identifier-domains/expected.txt b/tests/i/identifier-domains/expected.txt new file mode 100644 index 0000000..95fa0cf --- /dev/null +++ b/tests/i/identifier-domains/expected.txt @@ -0,0 +1,7 @@ +4 +6 +7:TRUE +8:9 +5:3 +5 +3 diff --git a/tests/i/identifier-domains/notes.md b/tests/i/identifier-domains/notes.md new file mode 100644 index 0000000..1a03605 --- /dev/null +++ b/tests/i/identifier-domains/notes.md @@ -0,0 +1,5 @@ +# identifier-domains + +Human review: pending. Expected output was independently traced, not captured from cpsc. + +CIE pp. 7, 28: names ignore case and omitted class access is public. The array is changed by reference to 4 and 6; the node is changed through its pointer to 7; Summer is the second enumerator. Class fields hold 8 and 9. The string length is 5 and the native int cast is 3. A block shadows Limit with 5, then restores 3. The function and procedure calls precede their definitions. diff --git a/tests/i/identifier-domains/program.cps b/tests/i/identifier-domains/program.cps new file mode 100644 index 0000000..d1b684b --- /dev/null +++ b/tests/i/identifier-domains/program.cps @@ -0,0 +1,43 @@ +TYPE Node + DECLARE Value : INTEGER +ENDTYPE +TYPE Link = ^Node +TYPE Season = (Spring, Summer) +TYPE Signed = C_TYPE("int") +CLASS Box + Value : INTEGER + PUBLIC Other : INTEGER + PRIVATE Hidden : INTEGER +ENDCLASS +CONSTANT Limit = 3 +DECLARE Item : nODE +DECLARE Ptr : lINK +DECLARE Mode : sEASON +DECLARE Crate : bOX +DECLARE Items : ARRAY[1:2] OF INTEGER +DECLARE Index : INTEGER +item.value <- limit +pTR <- ^ITEM +ptr^.vALUE <- 7 +mode <- sUMMER +crate.value <- 8 +CRATE.other <- 9 +CALL cHANGE(iTEMS) +FOR Index <- 1 TO 2 + OUTPUT items[index] +NEXT iNDEX +OUTPUT rEADnODE(ITEM), ":", MODE = summer +OUTPUT crate.VALUE, ":", crate.OTHER +OUTPUT length("MiXeD"), ":", (sIGNED)3 +IF TRUE THEN + CONSTANT lIMIT = 5 + OUTPUT LIMIT +ENDIF +OUTPUT Limit +PROCEDURE Change(BYREF Values : ARRAY OF INTEGER) + vALUES[1] <- 4 + VALUES[2] <- 6 +ENDPROCEDURE +FUNCTION ReadNode(Value : NODE) RETURNS INTEGER + RETURN vALUE.Value +ENDFUNCTION diff --git a/tests/i/integer-literal-contexts/case.json b/tests/i/integer-literal-contexts/case.json new file mode 100644 index 0000000..1f18635 --- /dev/null +++ b/tests/i/integer-literal-contexts/case.json @@ -0,0 +1,3 @@ +{ + "exit_code": 0 +} diff --git a/tests/i/integer-literal-contexts/expected.txt b/tests/i/integer-literal-contexts/expected.txt new file mode 100644 index 0000000..e23c6cc --- /dev/null +++ b/tests/i/integer-literal-contexts/expected.txt @@ -0,0 +1,3 @@ +9223372036854775807 +-9223372036854775808:9223372036854775807 +0:-1:-3 diff --git a/tests/i/integer-literal-contexts/notes.md b/tests/i/integer-literal-contexts/notes.md new file mode 100644 index 0000000..6285895 --- /dev/null +++ b/tests/i/integer-literal-contexts/notes.md @@ -0,0 +1,5 @@ +# integer-literal-contexts + +Human review: pending. Expected output was independently traced, not captured from cpsc. + +The i64 endpoints are exact in constants, expressions and signed parameter bounds. The array has one element, containing Maximum. Ordinary unary negation still yields 0, -1 and -3. diff --git a/tests/i/integer-literal-contexts/program.cps b/tests/i/integer-literal-contexts/program.cps new file mode 100644 index 0000000..3ebc7fb --- /dev/null +++ b/tests/i/integer-literal-contexts/program.cps @@ -0,0 +1,10 @@ +CONSTANT Minimum = -9223372036854775808 +CONSTANT Maximum = 9223372036854775807 +DECLARE Values : ARRAY[-9223372036854775808:-9223372036854775808] OF INTEGER +Values[Minimum] <- Maximum +CALL Show(Values) +OUTPUT Minimum, ":", Maximum +OUTPUT -0, ":", -1, ":", -(1 + 2) +PROCEDURE Show(BYREF Items : ARRAY[-9223372036854775808:-9223372036854775808] OF INTEGER) + OUTPUT Items[-9223372036854775808] +ENDPROCEDURE diff --git a/tests/i/loops/notes.md b/tests/i/loops/notes.md index 6979d92..bdd322a 100644 --- a/tests/i/loops/notes.md +++ b/tests/i/loops/notes.md @@ -6,4 +6,4 @@ Basis: CIE pp. 20-21. Trace: FOR contributions are 0, 2, and 3+1-1=3. WHILE contributes 0+1+2=3. REPEAT contributes 10 once, then counts to 3. Total=18. -The project requires DO after WHILE; this fixture uses that spelling to exercise runtime semantics. The separate standard-while fixture tests the CIE spelling. +WHILE headers use the standard CIE spelling without DO. The separate standard-while fixture also checks this syntax. diff --git a/tests/i/loops/program.cps b/tests/i/loops/program.cps index a858e6c..d30b463 100644 --- a/tests/i/loops/program.cps +++ b/tests/i/loops/program.cps @@ -10,11 +10,11 @@ NEXT I FOR I <- 3 TO -1 STEP -2 Total <- Total + I NEXT I -WHILE FALSE DO +WHILE FALSE Total <- Total + 1000 ENDWHILE I <- 0 -WHILE I < 3 DO +WHILE I < 3 Total <- Total + I I <- I + 1 ENDWHILE diff --git a/tests/i/text-files/notes.md b/tests/i/text-files/notes.md index cc62aea..1b2ecad 100644 --- a/tests/i/text-files/notes.md +++ b/tests/i/text-files/notes.md @@ -6,4 +6,4 @@ Basis: CIE p. 25; CRLF input handling follows project text-file semantics. Trace: Input contains three lines, including an empty line and a last line without terminator. Empty-file EOF is true. WRITE replaces old contents; APPEND adds last after the existing blank line. -The project requires DO after WHILE; this fixture uses that spelling to exercise runtime semantics. The separate standard-while fixture tests the CIE spelling. +WHILE headers use the standard CIE spelling without DO. The separate standard-while fixture also checks this syntax. diff --git a/tests/i/text-files/program.cps b/tests/i/text-files/program.cps index 1d6d5bb..42632fd 100644 --- a/tests/i/text-files/program.cps +++ b/tests/i/text-files/program.cps @@ -2,7 +2,7 @@ DECLARE Line : STRING DECLARE Count : INTEGER OPENFILE "input.txt" FOR READ Count <- 0 -WHILE NOT EOF("input.txt") DO +WHILE NOT EOF("input.txt") READFILE "input.txt", Line OUTPUT "[", Line, "]" Count <- Count + 1 @@ -19,7 +19,7 @@ OPENFILE "result.txt" FOR APPEND WRITEFILE "result.txt", "last" CLOSEFILE "result.txt" OPENFILE "result.txt" FOR READ -WHILE NOT EOF("result.txt") DO +WHILE NOT EOF("result.txt") READFILE "result.txt", Line OUTPUT "[", Line, "]" ENDWHILE |
