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/program.cps | |
| 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/program.cps')
| -rw-r--r-- | tests/i/string-values/program.cps | 40 |
1 files changed, 40 insertions, 0 deletions
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 |
