summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2018-12-19 12:38:50 -0800
committerTimothee Cour <timothee.cour2@gmail.com>2018-12-19 16:11:23 -0800
commitfc7df3283c11c71c60d079b5aea7deb70ffcb559 (patch)
treee572e946ae288db15893b6c79a021e6f944d225c
parent8fbe3b3b7d6b6cd19a71c238034524dc64aa703b (diff)
downloadNim-fc7df3283c11c71c60d079b5aea7deb70ffcb559.tar.gz
fix test failure
-rw-r--r--lib/pure/os.nim6
-rw-r--r--tests/stdlib/tos.nim1
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 46e4e7b69..2919b39f0 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -349,10 +349,12 @@ proc splitFile*(path: string): tuple[dir, name, ext: string] {.
   ## If `path` has no extension, `ext` is the empty string.
   ## If `path` has no directory component, `dir` is the empty string.
   ## If `path` has no filename component, `name` and `ext` are empty strings.
-  if path.len == 0 or path[^1] in {DirSep, AltSep}:
+  if path.len == 0:
+      result = ("", "", "")
+  elif path[^1] in {DirSep, AltSep}:
     if path.len == 1:
       # issue #8255
-      result = (path[0 .. ^1], "", "")
+      result = ($path[0], "", "")
     else:
       result = (path[0 ..< ^1], "", "")
   else:
diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim
index e49ab2506..577baea87 100644
--- a/tests/stdlib/tos.nim
+++ b/tests/stdlib/tos.nim
@@ -240,6 +240,7 @@ block absolutePath:
     doAssert absolutePath("/a", "b/") == "/a"
 
 block splitFile:
+  doAssert splitFile("") == ("", "", "")
   doAssert splitFile("abc/") == ("abc", "", "")
   doAssert splitFile("/") == ("/", "", "")
   doAssert splitFile("./abc") == (".", "abc", "")