diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-20 11:57:16 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-20 11:57:16 +0000 |
| commit | 62b605c6c0ea13e9763c0a0115464007b13a8831 (patch) | |
| tree | 53c27965f5a365682e0d79fd96e25b228ecb9dca /tests/i/string-values | |
| parent | bfe2e75d7e3b372e55369677028429990c49bc54 (diff) | |
refactor(strings): replace compiler builtins with the STRING library
Construct literals as STRING values and route string operations through
ordinary library functions and operators. Preserve value ownership in
records, arrays, constants and file I/O.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/string-values')
| -rw-r--r-- | tests/i/string-values/case.json | 1 | ||||
| -rw-r--r-- | tests/i/string-values/expected.txt | 8 | ||||
| -rw-r--r-- | tests/i/string-values/notes.md | 5 | ||||
| -rw-r--r-- | tests/i/string-values/program.cps | 40 |
4 files changed, 54 insertions, 0 deletions
diff --git a/tests/i/string-values/case.json b/tests/i/string-values/case.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/i/string-values/case.json @@ -0,0 +1 @@ +{} diff --git a/tests/i/string-values/expected.txt b/tests/i/string-values/expected.txt new file mode 100644 index 0000000..e8badf2 --- /dev/null +++ b/tests/i/string-values/expected.txt @@ -0,0 +1,8 @@ +constant:independent:global:local +changed:two +one +two +TRUE:TRUE:TRUE:TRUE:TRUE +1:1 +matched +B diff --git a/tests/i/string-values/notes.md b/tests/i/string-values/notes.md new file mode 100644 index 0000000..1e821cc --- /dev/null +++ b/tests/i/string-values/notes.md @@ -0,0 +1,5 @@ +# String values + +Human review: pending. Expected output is traced from independent string values. + +Record copies and BYVAL array calls must preserve the source when a copy changes. Self-assignment preserves the value. Global and constant strings remain available to functions. Comparisons use case-sensitive content ordering. Ordinary literals retain the legacy NUL truncation; CHR can construct an owning one-byte NUL string. diff --git a/tests/i/string-values/program.cps b/tests/i/string-values/program.cps new file mode 100644 index 0000000..46822fc --- /dev/null +++ b/tests/i/string-values/program.cps @@ -0,0 +1,40 @@ +GLOBAL + DECLARE Label : STRING + Label <- "global" +ENDGLOBAL +CONSTANT Greeting = "constant" +TYPE Item + DECLARE Text : STRING +ENDTYPE +FUNCTION ReadConstant() RETURNS STRING + CONSTANT Local = "local" + RETURN Local +ENDFUNCTION +FUNCTION Echo(Value : Item) RETURNS Item + RETURN Value +ENDFUNCTION +PROCEDURE Change(Values : ARRAY OF STRING) + Values[1] <- "changed" + OUTPUT Values[1], ":", Values[2] +ENDPROCEDURE +DECLARE A : Item +DECLARE B : Item +A.Text <- Greeting +B <- Echo(A) +B.Text <- "independent" +B <- B +OUTPUT A.Text, ":", B.Text, ":", Label, ":", ReadConstant() +DECLARE Values : ARRAY[1:2] OF STRING +Values[1] <- "one" +Values[2] <- "two" +CALL Change(Values) +OUTPUT Values +OUTPUT "A" < "B", ":", "B" > "A", ":", "A" <= "A", ":", "B" >= "A", ":", "a" <> "A" +OUTPUT LENGTH("a\0b"), ":", LENGTH(CHR(0)) +DECLARE Selected : STRING +Selected <- "B" +CASE OF Selected + "A" : OUTPUT "wrong" + "B" : OUTPUT "matched" +ENDCASE +OUTPUT Selected |
