fix test failure

This commit is contained in:
Timothee Cour 2018-12-19 12:38:50 -08:00
commit fc7df3283c
2 changed files with 5 additions and 2 deletions

View file

@ -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 extension, `ext` is the empty string.
## If `path` has no directory component, `dir` 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` 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: if path.len == 1:
# issue #8255 # issue #8255
result = (path[0 .. ^1], "", "") result = ($path[0], "", "")
else: else:
result = (path[0 ..< ^1], "", "") result = (path[0 ..< ^1], "", "")
else: else:

View file

@ -240,6 +240,7 @@ block absolutePath:
doAssert absolutePath("/a", "b/") == "/a" doAssert absolutePath("/a", "b/") == "/a"
block splitFile: block splitFile:
doAssert splitFile("") == ("", "", "")
doAssert splitFile("abc/") == ("abc", "", "") doAssert splitFile("abc/") == ("abc", "", "")
doAssert splitFile("/") == ("/", "", "") doAssert splitFile("/") == ("/", "", "")
doAssert splitFile("./abc") == (".", "abc", "") doAssert splitFile("./abc") == (".", "abc", "")