summary refs log tree commit diff stats
path: root/tests/js
diff options
context:
space:
mode:
authorZoom <ZoomRmc@users.noreply.github.com>2023-06-21 06:52:33 +0000
committerGitHub <noreply@github.com>2023-06-21 08:52:33 +0200
commit5e529b3bfa7b3ca09cde7237134acd47e47ca48c (patch)
treef85af533ea8c251a48bddac06a600069be0bcc4a /tests/js
parenta345cde26e15ef8e1c905c48507195739fab4515 (diff)
downloadNim-5e529b3bfa7b3ca09cde7237134acd47e47ca48c.tar.gz
`strutils.split/rsplit` now return src on an empty sep (#22136)
This is a rebase of an earlier rejected PR. Following the discussion
around it, this commit provides a valid output for and edge case
of an empty separator for `split` and `rsplit` routines. The empty
separator is interpreted as "split by no separators" and the initial
string is returned. This is consistent with the behaviour of the
`set[char]` version of `split`/`rsplit` routines and unifies them all.

Compared to a commit merged earlier, this one has a benefit of
not using assertions that will be removed in release builds
and thus still not preventing possible infinite loops (which was the
earlier behaviour for this edge case for separator of type `string`).

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/js')
-rw-r--r--tests/js/tstdlib_various.nim7
1 files changed, 1 insertions, 6 deletions
diff --git a/tests/js/tstdlib_various.nim b/tests/js/tstdlib_various.nim
index 4b5ce1de8..1e584f735 100644
--- a/tests/js/tstdlib_various.nim
+++ b/tests/js/tstdlib_various.nim
@@ -150,12 +150,7 @@ block tsplit2:
     s.add("#")
     s.add(w)
 
-  var errored = false
-  try:
-    discard "hello".split("")
-  except AssertionDefect:
-    errored = true
-  doAssert errored
+  doAssert "true".split("") == @["true"]
 
 block txmlgen:
   var nim = "Nim"