diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-20 10:56:22 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-20 10:56:22 +0000 |
| commit | cf9af14fe749c52473fdf5a327c3e935e45bf0e7 (patch) | |
| tree | 4c22c4a919e3da709b16055ff6762ea1195b6237 /tests/library/exp-string | |
| parent | 1ed0e276a37d39386b22b08c1f9e575a8f8f8725 (diff) | |
feat(library): add experimental string LEFT function
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/library/exp-string')
| -rw-r--r-- | tests/library/exp-string/expected.txt | 4 | ||||
| -rw-r--r-- | tests/library/exp-string/notes.md | 2 | ||||
| -rw-r--r-- | tests/library/exp-string/program.cps | 5 |
3 files changed, 11 insertions, 0 deletions
diff --git a/tests/library/exp-string/expected.txt b/tests/library/exp-string/expected.txt index fab16b1..19f0d9b 100644 --- a/tests/library/exp-string/expected.txt +++ b/tests/library/exp-string/expected.txt @@ -8,3 +8,7 @@ TRUE conversion caught length caught heap +ABC +0:0:0 +ABCDEFGH +4 diff --git a/tests/library/exp-string/notes.md b/tests/library/exp-string/notes.md index ca7d489..f44a2b3 100644 --- a/tests/library/exp-string/notes.md +++ b/tests/library/exp-string/notes.md @@ -3,3 +3,5 @@ Review status: pending human review. Copies of hello are independent; assigning world to the copy gives helloworld when concatenated. Empty length is zero, and three NUL bytes retain length three. One hundred appended five-byte words grow 20000 bytes to 20500, preserved by BYVAL and RETURN. C++17 formatting gives 42 and 1.250000. Parsing 12.5 compares equal to 12.5. Trailing junk and negative counts emit the explicit library reasons at user lines 27 and 32, then are caught. Discarded numeric and Echo results must release their owned strings at statement end. The explicitly deleted heap object prints heap. This fixture covers compiler/library extensions, including numeric text formatting. + +LEFT keeps ABC, returns zero bytes for an empty source or nonpositive count, and clamps 20 to all eight letters. Taking four bytes from three NULs followed by hello retains all four bytes. diff --git a/tests/library/exp-string/program.cps b/tests/library/exp-string/program.cps index 719d9a4..c9dad8a 100644 --- a/tests/library/exp-string/program.cps +++ b/tests/library/exp-string/program.cps @@ -39,3 +39,8 @@ DECLARE Heap : _EXP_STRING Heap <- NEW _EXP_STRING((C_STRING)"heap") CALL _EXP_STRING_OUTPUT(Heap) DELETE Heap +DECLARE Letters : _EXP_STRING((C_STRING)"ABCDEFGH") +CALL _EXP_STRING_OUTPUT(_EXP_STRING_LEFT(Letters, 3)) +OUTPUT _EXP_STRING_LENGTH(_EXP_STRING_LEFT(Empty, 2)), ":", _EXP_STRING_LENGTH(_EXP_STRING_LEFT(Letters, 0)), ":", _EXP_STRING_LENGTH(_EXP_STRING_LEFT(Letters, -1)) +CALL _EXP_STRING_OUTPUT(_EXP_STRING_LEFT(Letters, 20)) +OUTPUT _EXP_STRING_LENGTH(_EXP_STRING_LEFT(Nuls & A, 4)) |
