Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jul 7, 2018
1 parent da973ef commit 57fdb18
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,13 @@ proc absolutePath*(path: string, root = getCurrentDir()): string =
doAssert absolutePath("a") == getCurrentDir() / "a"
if isAbsolute(path): path
else:
doAssert root.isAbsolute, root
if not root.isAbsolute:
# CHECKME: is that the correct exception type?
raise newException(ValueError, root)
joinPath(root, path)

when isMainModule:
# TODO: use doAssertRaises pending https://github.com/nim-lang/Nim/issues/8223
try:
let a = absolutePath("a", "b")
doAssert false, "should've thrown"
except:
discard

doAssertRaises(ValueError): discard absolutePath("a", "b")
doAssert absolutePath("a") == getCurrentDir() / "a"
doAssert absolutePath("a", "/b") == "/b" / "a"
when defined(Posix):
Expand Down

0 comments on commit 57fdb18

Please sign in to comment.