diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-30 14:31:07 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-30 14:31:07 +0000 |
| commit | 0cf54b4f77ccf8376341950b02ceb7c1d1268ed7 (patch) | |
| tree | eebbba01063451c28f0a2e1cc048215f50beb98f /tests | |
| parent | 4cb0d9b196008bc55dbfcdac1f9211dbbc879895 (diff) | |
refactor(strings): construct string values implicitly from raw literals
Keep double-quoted literals and text constants as C_STRING values. Use
marked STRING constructors for text and CHAR conversion, preserving
string operations and I/O through the existing class machinery.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i/c-string-literals/expected.txt | 2 | ||||
| -rw-r--r-- | tests/i/c-string-literals/notes.md | 2 | ||||
| -rw-r--r-- | tests/i/custom-string/program.cps | 2 | ||||
| -rw-r--r-- | tests/iii/class-new-errors/case.json | 2 | ||||
| -rw-r--r-- | tests/iii/implicit-string-opt-in/case.json | 15 | ||||
| -rw-r--r-- | tests/iii/implicit-string-opt-in/program.cps | 14 | ||||
| -rw-r--r-- | tests/iii/overload-errors/case.json | 2 | ||||
| -rw-r--r-- | tests/iii/string-type-mismatch/case.json | 2 |
8 files changed, 35 insertions, 6 deletions
diff --git a/tests/i/c-string-literals/expected.txt b/tests/i/c-string-literals/expected.txt index 2255027..ba0bd18 100644 --- a/tests/i/c-string-literals/expected.txt +++ b/tests/i/c-string-literals/expected.txt @@ -1,4 +1,4 @@ quote:" slash:\ AB 0 -1:2 +2:2 diff --git a/tests/i/c-string-literals/notes.md b/tests/i/c-string-literals/notes.md index a469ce1..a146f16 100644 --- a/tests/i/c-string-literals/notes.md +++ b/tests/i/c-string-literals/notes.md @@ -2,4 +2,4 @@ Human review: pending. Expectations follow the literal bytes and declared overloads. -The adjacent uppercase C suffix produces C_STRING. Escapes use the ordinary lexer rules. Explicit STRING casts preserve the text; an empty C string has length zero after conversion. Overload selection distinguishes STRING from C_STRING. +The adjacent uppercase C suffix produces C_STRING. Escapes use the ordinary lexer rules. Explicit STRING casts preserve the text; an empty C string has length zero after conversion. Both ordinary and suffixed literals have type C_STRING, so both calls select the exact C_STRING overload. diff --git a/tests/i/custom-string/program.cps b/tests/i/custom-string/program.cps index cf2bb24..93dcba5 100644 --- a/tests/i/custom-string/program.cps +++ b/tests/i/custom-string/program.cps @@ -1,6 +1,6 @@ CLASS STRING Text : C_STRING - PROCEDURE NEW(Value : C_STRING) + IMPLICIT PROCEDURE NEW(Value : C_STRING) Text <- Value ENDPROCEDURE FUNCTION C_STR() RETURNS C_STRING diff --git a/tests/iii/class-new-errors/case.json b/tests/iii/class-new-errors/case.json index 5323679..982b80c 100644 --- a/tests/iii/class-new-errors/case.json +++ b/tests/iii/class-new-errors/case.json @@ -37,7 +37,7 @@ "line": 30 }, { - "reason": "Cannot use a value of type STRING where INTEGER is expected", + "reason": "Cannot implicitly convert C_STRING to INTEGER", "line": 31 } ] diff --git a/tests/iii/implicit-string-opt-in/case.json b/tests/iii/implicit-string-opt-in/case.json new file mode 100644 index 0000000..8fae19d --- /dev/null +++ b/tests/iii/implicit-string-opt-in/case.json @@ -0,0 +1,15 @@ +{ + "compiler_args": [ + "-no-std" + ], + "errors": [ + { + "line": 13, + "reason": "Cannot implicitly convert C_STRING to STRING" + }, + { + "line": 14, + "reason": "STRING requires an IMPLICIT constructor NEW" + } + ] +} diff --git a/tests/iii/implicit-string-opt-in/program.cps b/tests/iii/implicit-string-opt-in/program.cps new file mode 100644 index 0000000..b5afccc --- /dev/null +++ b/tests/iii/implicit-string-opt-in/program.cps @@ -0,0 +1,14 @@ +CLASS STRING + Text : C_STRING + PROCEDURE NEW(Value : C_STRING) + Text <- Value + ENDPROCEDURE + FUNCTION C_STR() RETURNS C_STRING + RETURN Text + ENDFUNCTION +ENDCLASS +DECLARE Explicit : STRING("explicit") +OUTPUT Explicit +DECLARE Text : STRING +Text <- "requires opt-in" +OUTPUT "requires opt-in" diff --git a/tests/iii/overload-errors/case.json b/tests/iii/overload-errors/case.json index 6e2156e..4608bf6 100644 --- a/tests/iii/overload-errors/case.json +++ b/tests/iii/overload-errors/case.json @@ -21,7 +21,7 @@ "line": 25 }, { - "reason": "No matching overload for Exact\\(STRING\\)", + "reason": "No matching overload for Exact\\(C_STRING\\)", "line": 28 }, { diff --git a/tests/iii/string-type-mismatch/case.json b/tests/iii/string-type-mismatch/case.json index 3471178..3a8ed29 100644 --- a/tests/iii/string-type-mismatch/case.json +++ b/tests/iii/string-type-mismatch/case.json @@ -1,7 +1,7 @@ { "errors": [ { - "reason": "Operator = cannot be applied to STRING and INTEGER", + "reason": "C and pseudocode operands require an explicit cast", "line": 2 } ] |
