aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-20 11:04:39 +0000
committer_ov4 <ov4@ov4.org>2026-10-20 11:04:39 +0000
commit52e0674c54d4b53b2132e750106cc9acb266ed39 (patch)
tree9d605a6ca2bd6aa894dc46e18dc86da8298bf61d /tests
parent8975d167c849f54664be8d5da418cd909694d26f (diff)
feat(library): add experimental string IS_NUM function
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/library/exp-string/expected.txt3
-rw-r--r--tests/library/exp-string/notes.md2
-rw-r--r--tests/library/exp-string/program.cps13
3 files changed, 18 insertions, 0 deletions
diff --git a/tests/library/exp-string/expected.txt b/tests/library/exp-string/expected.txt
index 0680cf2..030a4c2 100644
--- a/tests/library/exp-string/expected.txt
+++ b/tests/library/exp-string/expected.txt
@@ -39,3 +39,6 @@ AZ
65
1:0
65:255
+TRUE:FALSE:FALSE
+TRUE:FALSE:FALSE
+FALSE:FALSE
diff --git a/tests/library/exp-string/notes.md b/tests/library/exp-string/notes.md
index 7eddda1..e2a1bbc 100644
--- a/tests/library/exp-string/notes.md
+++ b/tests/library/exp-string/notes.md
@@ -19,3 +19,5 @@ UCASE converts AbC@19 to ABC@19 without modifying the source. Its CHAR overload
ASC returns 65 for CHAR A and the first byte of ABCDEFGH, zero for empty strings or NUL, and 255 for a byte with all eight bits set. These byte-code functions are compiler/library extensions.
CHR codes 65 and 90 concatenate to AZ; converting A to a code and back preserves 65. Code zero produces one retained NUL byte. Taking the low eight bits gives 65 for 321 and 255 for -1.
+
+IS_NUM accepts 12.5 and a leading space before 12.5. It rejects trailing junk, empty input, trailing space, whitespace alone, and a NUL byte before or after a valid number, without throwing. Numeric recognition follows the compiler's strtod-based extension.
diff --git a/tests/library/exp-string/program.cps b/tests/library/exp-string/program.cps
index e789e54..0adf86c 100644
--- a/tests/library/exp-string/program.cps
+++ b/tests/library/exp-string/program.cps
@@ -46,6 +46,7 @@ CALL CheckLCase()
CALL CheckUCase()
CALL CheckAsc()
CALL CheckChr()
+CALL CheckIsNum()
PROCEDURE CheckLeft()
DECLARE Letters : _EXP_STRING((C_STRING)"ABCDEFGH")
@@ -123,3 +124,15 @@ PROCEDURE CheckChr()
OUTPUT _EXP_STRING_LENGTH(_EXP_STRING_CHR(0)), ":", _EXP_STRING_ASC(_EXP_STRING_CHR(0))
OUTPUT _EXP_STRING_ASC(_EXP_STRING_CHR(321)), ":", _EXP_STRING_ASC(_EXP_STRING_CHR(-1))
ENDPROCEDURE
+
+PROCEDURE CheckIsNum()
+ DECLARE Number : _EXP_STRING((C_STRING)"12.5")
+ DECLARE Junk : _EXP_STRING((C_STRING)"12x")
+ DECLARE Empty : _EXP_STRING
+ DECLARE Leading : _EXP_STRING((C_STRING)" 12.5")
+ DECLARE Trailing : _EXP_STRING((C_STRING)"12.5 ")
+ DECLARE Whitespace : _EXP_STRING((C_STRING)" ")
+ OUTPUT _EXP_STRING_IS_NUM(Number), ":", _EXP_STRING_IS_NUM(Junk), ":", _EXP_STRING_IS_NUM(Empty)
+ OUTPUT _EXP_STRING_IS_NUM(Leading), ":", _EXP_STRING_IS_NUM(Trailing), ":", _EXP_STRING_IS_NUM(Whitespace)
+ OUTPUT _EXP_STRING_IS_NUM(Number & _EXP_STRING_CHR(0)), ":", _EXP_STRING_IS_NUM(_EXP_STRING_CHR(0) & Number)
+ENDPROCEDURE