summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorChris Heller <chris.heller@greyheller.com>2016-12-16 01:33:44 -0800
committerChris Heller <chris.heller@greyheller.com>2016-12-21 12:06:59 -0800
commit40d034b7e37dd3d19f324ec8bcef5fafc03fed2a (patch)
tree27499ca97467b2d22ab318833e806749de97a0d3 /tests/stdlib
parent2bb49136de3e3d798c4bf37d23f34ee868e7ebf7 (diff)
downloadNim-40d034b7e37dd3d19f324ec8bcef5fafc03fed2a.tar.gz
Guard against calling split with an empty string as a separator. Fixes #5119
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tsplit2.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/stdlib/tsplit2.nim b/tests/stdlib/tsplit2.nim
new file mode 100644
index 000000000..5c4245d54
--- /dev/null
+++ b/tests/stdlib/tsplit2.nim
@@ -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 ValueError:
+  echo "true"
+
+#OUT true
+