diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2018-12-19 12:38:50 -0800 |
---|---|---|
committer | Timothee Cour <timothee.cour2@gmail.com> | 2018-12-19 16:11:23 -0800 |
commit | fc7df3283c11c71c60d079b5aea7deb70ffcb559 (patch) | |
tree | e572e946ae288db15893b6c79a021e6f944d225c | |
parent | 8fbe3b3b7d6b6cd19a71c238034524dc64aa703b (diff) | |
download | Nim-fc7df3283c11c71c60d079b5aea7deb70ffcb559.tar.gz |
fix test failure
-rw-r--r-- | lib/pure/os.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/tos.nim | 1 |
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", "") |