Skip to content

Commit

Permalink
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Dec 22, 2016
2 parents 7bd473c + 7ee3cdc commit 0f9d746
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/pure/strutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ proc split*(s: string, sep: string, maxsplit: int = -1): seq[string] {.noSideEff
##
## Substrings are separated by the string `sep`. This is a wrapper around the
## `split iterator <#split.i,string,string>`_.
doAssert(sep.len > 0)

accumulateResult(split(s, sep, maxsplit))

proc rsplit*(s: string, seps: set[char] = Whitespace,
Expand Down
19 changes: 19 additions & 0 deletions tests/stdlib/tsplit2.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
discard """
file: "tsplit2.nim"
output: "true"
"""
import strutils

var s = ""
for w in split("|abc|xy|z", {'|'}):
s.add("#")
s.add(w)

try:
discard "hello".split("")
echo "false"
except AssertionError:
echo "true"

#OUT true

0 comments on commit 0f9d746

Please sign in to comment.