diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-18 08:16:01 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-18 08:16:01 +0000 |
| commit | 14c03b7c26ff06835fca631eed6a3e308946321a (patch) | |
| tree | 33965d73902f019f2f778046e7f097ff26f35f01 /tests/library/exp-string/program.cps | |
| parent | 0b1c500e9cbc7837dbef5fb24be21dc4f6078714 (diff) | |
feat(lib): add experimental _EXP_STRING backed by std::string
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/library/exp-string/program.cps')
| -rw-r--r-- | tests/library/exp-string/program.cps | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/library/exp-string/program.cps b/tests/library/exp-string/program.cps new file mode 100644 index 0000000..719d9a4 --- /dev/null +++ b/tests/library/exp-string/program.cps @@ -0,0 +1,41 @@ +INCLUDE "../../../pseudocode-lib/_exp_string.cps" +FUNCTION Echo(S : _EXP_STRING) RETURNS _EXP_STRING + RETURN S +ENDFUNCTION +DECLARE A : _EXP_STRING((C_STRING)"hello") +DECLARE B : _EXP_STRING(A) +B <- (C_STRING)"world" +B <- B +CALL _EXP_STRING_OUTPUT(A & B) +DECLARE Empty : _EXP_STRING +OUTPUT _EXP_STRING_LENGTH(Empty) +DECLARE Nuls : _EXP_STRING(3, (C_CHAR)'\0') +OUTPUT _EXP_STRING_LENGTH(Nuls) +DECLARE Long : _EXP_STRING(20000, (C_CHAR)'x') +DECLARE I : INTEGER +FOR I <- 1 TO 100 + Long <- Long & A +NEXT I +OUTPUT _EXP_STRING_LENGTH(Long) +Long <- Echo(Long) +OUTPUT _EXP_STRING_LENGTH(Long) +CALL _EXP_STRING_OUTPUT(_EXP_STRING_NUM_TO_STR(42) & _EXP_STRING_NUM_TO_STR(1.25)) +DECLARE Number : _EXP_STRING((C_STRING)"12.5") +OUTPUT _EXP_STRING_STR_TO_NUM(Number) = 12.5 +TRY + Number <- (C_STRING)"12x" + OUTPUT _EXP_STRING_STR_TO_NUM(Number) +CATCH + OUTPUT "conversion caught" +ENDTRY +TRY + DECLARE Invalid : _EXP_STRING(-1, (C_CHAR)'x') +CATCH + OUTPUT "length caught" +ENDTRY +CALL _EXP_STRING_NUM_TO_STR(99) +CALL Echo(Long) +DECLARE Heap : _EXP_STRING +Heap <- NEW _EXP_STRING((C_STRING)"heap") +CALL _EXP_STRING_OUTPUT(Heap) +DELETE Heap |
