Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Aug 27, 2018
1 parent ed2bbf0 commit 924c963
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
13 changes: 0 additions & 13 deletions lib/pure/ospaths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -721,18 +721,6 @@ when defined(windows) or defined(posix) or defined(nintendoswitch):
result.add quoteShell(args[i])

when isMainModule:
assert quoteShellWindows("aaa") == "aaa"
assert quoteShellWindows("aaa\"") == "aaa\\\""
assert quoteShellWindows("") == "\"\""

assert quoteShellPosix("aaa") == "aaa"
assert quoteShellPosix("aaa a") == "'aaa a'"
assert quoteShellPosix("") == "''"
assert quoteShellPosix("a'a") == "'a'\"'\"'a'"

when defined(posix):
assert quoteShell("") == "''"

block normalizePathEndTest:
# handle edge cases correctly: shouldn't affect whether path is
# absolute/relative
Expand Down Expand Up @@ -765,4 +753,3 @@ when isMainModule:
doAssert r"C:\foo".rootPrefixLength == 3
doAssert r"//foo".rootPrefixLength == 2
doAssert r"C:\\foo".rootPrefixLength == 4

25 changes: 14 additions & 11 deletions tests/stdlib/tospaths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ block unixToNativePath:
doAssert unixToNativePath("/abc", "a") == "/abc"
doAssert unixToNativePath("/abc/def", "a") == "/abc/def"

block normalizePathEnd:
doAssert "".normalizePathEnd == ""
doAssert "".normalizePathEnd(trailingSep = true) == ""
when defined(posix):
doAssert "/".normalizePathEnd == "/"
doAssert "foo.bar".normalizePathEnd == "foo.bar"
doAssert "foo.bar".normalizePathEnd(trailingSep = true) == "foo.bar/"
when defined(Windows):
doAssert r"C:\\".normalizePathEnd == r"C:\"
doAssert r"C:\".normalizePathEnd(trailingSep = true) == r"C:\"
doAssert r"C:\foo\\bar\".normalizePathEnd == r"C:\foo\\bar"

block joinPath:
when defined(posix):
doAssert joinPath("", "/lib") == "/lib"

block quoteShellWindowsTest:
assert quoteShellWindows("aaa") == "aaa"
assert quoteShellWindows("aaa\"") == "aaa\\\""
assert quoteShellWindows("") == "\"\""

block quoteShellPosixTest:
assert quoteShellPosix("aaa") == "aaa"
assert quoteShellPosix("aaa a") == "'aaa a'"
assert quoteShellPosix("") == "''"
assert quoteShellPosix("a'a") == "'a'\"'\"'a'"

block quoteShellTest:
when defined(posix):
assert quoteShell("") == "''"

0 comments on commit 924c963

Please sign in to comment.