fix test failure

This commit is contained in:
Timothee Cour
2018-12-19 12:38:50 -08:00
parent 8fbe3b3b7d
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 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:

View File

@@ -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", "")