aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-05-20 09:34:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-05-20 09:34:16 +0200
commit2fc53c801eb551154f0a2aa96522cf3182a65b7a (patch)
treeed48460199846d853ac4be7deecc7f16bb478976 /tests
parent4543814cc2951f9d8ccd914253be2954acb9ba41 (diff)
Add $string.contains(), $string.starts_with(), $string.ends_with()
Also fix bug in $string.replace().
Diffstat (limited to 'tests')
-rw-r--r--tests/function/string/testscript72
1 files changed, 67 insertions, 5 deletions
diff --git a/tests/function/string/testscript b/tests/function/string/testscript
index 244ace8..8eb5760 100644
--- a/tests/function/string/testscript
+++ b/tests/function/string/testscript
@@ -25,17 +25,79 @@
}
}
+: contains
+:
+{
+ : basics
+ :
+ {
+ $* <'print $string.contains( abcd, bc)' >'true' : true
+ $* <'print $string.contains( abcd, ac)' >'false' : false
+ $* <'print $contains([string] abcd, cd)' >'true' : typed
+ }
+
+ : icase
+ :
+ {
+ $* <'print $string.contains(aBcD, bC, icase)' >'true' : true
+ }
+
+ : once
+ :
+ {
+ $* <'print $string.contains(abcdabcd, da, once)' >'true' : true
+ $* <'print $string.contains(abcdabcd, bc, once)' >'false' : false
+ }
+}
+
+: starts_with
+:
+{
+ : basics
+ :
+ {
+ $* <'print $string.starts_with( abcd, ab)' >'true' : true
+ $* <'print $string.starts_with( abcd, bc)' >'false' : false
+ $* <'print $starts_with([string] abcd, abcd)' >'true' : typed
+ }
+
+ : icase
+ :
+ {
+ $* <'print $string.starts_with(aBcD, Ab, icase)' >'true' : true
+ }
+}
+
+: ends_with
+:
+{
+ : basics
+ :
+ {
+ $* <'print $string.ends_with( abcd, cd)' >'true' : true
+ $* <'print $string.ends_with( abcd, bc)' >'false' : false
+ $* <'print $ends_with([string] abcd, abcd)' >'true' : typed
+ }
+
+ : icase
+ :
+ {
+ $* <'print $string.ends_with(aBcD, Cd, icase)' >'true' : true
+ }
+}
+
: replace
:
{
: basics
:
{
- $* <'print $string.replace( abcb, b, BB)' >'aBBcBB' : expand
- $* <'print $string.replace( aabbccbb, bb, B)' >'aaBccB' : shrink
- $* <'print $replace([string] abc, b, B)' >'aBc' : typed
- $* <'print $replace([string] "", b, B)' >'' : empty
- $* <'print $replace([string] bbb, b, "")' >'' : to-empty
+ $* <'print $string.replace( abcb, b, BB)' >'aBBcBB' : expand
+ $* <'print $string.replace( aabbccbb, bb, B)' >'aaBccB' : shrink
+ $* <'print $replace([string] abc, b, B)' >'aBc' : typed
+ $* <'print $replace([string] "", b, B)' >'' : empty
+ $* <'print $replace([string] bbb, b, "")' >'' : to-empty
+ $* <'print $replace([string] bb, b, Bb)' >'BbBb' : no-recursion
}
: icase