diff options
author | Tomohiro <gpuppur@gmail.com> | 2018-07-03 00:14:26 +0900 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-07-02 17:14:26 +0200 |
commit | c79f488027239d1a43582cc52f0688b23cf504fb (patch) | |
tree | 53880505b77a7c55f36eec35cca6b92a77082e67 /tests | |
parent | 2c98b4943efb48cec01a63154bdf2cfb9da61714 (diff) | |
download | Nim-c79f488027239d1a43582cc52f0688b23cf504fb.tar.gz |
Fix os.unixToNativePath proc returns wrong result(#8179) (#8181)
* Fix os.unixToNativePath proc returns wrong result(#8179) * Add tests for unixToNativePath
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tospaths.nim | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/stdlib/tospaths.nim b/tests/stdlib/tospaths.nim new file mode 100644 index 000000000..0ac7729d9 --- /dev/null +++ b/tests/stdlib/tospaths.nim @@ -0,0 +1,41 @@ +discard """ + file: "tospaths.nim" + output: "" +""" +# test the ospaths module + +import os + +doAssert unixToNativePath("") == "" +doAssert unixToNativePath(".") == $CurDir +doAssert unixToNativePath("..") == $ParDir +doAssert isAbsolute(unixToNativePath("/")) +doAssert isAbsolute(unixToNativePath("/", "a")) +doAssert isAbsolute(unixToNativePath("/a")) +doAssert isAbsolute(unixToNativePath("/a", "a")) +doAssert isAbsolute(unixToNativePath("/a/b")) +doAssert isAbsolute(unixToNativePath("/a/b", "a")) +doAssert unixToNativePath("a/b") == joinPath("a", "b") + +when defined(macos): + doAssert unixToNativePath("./") == ":" + doAssert unixToNativePath("./abc") == ":abc" + doAssert unixToNativePath("../abc") == "::abc" + doAssert unixToNativePath("../../abc") == ":::abc" + doAssert unixToNativePath("/abc", "a") == "abc" + doAssert unixToNativePath("/abc/def", "a") == "abc:def" +elif doslikeFileSystem: + doAssert unixToNativePath("./") == ".\\" + doAssert unixToNativePath("./abc") == ".\\abc" + doAssert unixToNativePath("../abc") == "..\\abc" + doAssert unixToNativePath("../../abc") == "..\\..\\abc" + doAssert unixToNativePath("/abc", "a") == "a:\\abc" + doAssert unixToNativePath("/abc/def", "a") == "a:\\abc\\def" +else: + #Tests for unix + doAssert unixToNativePath("./") == "./" + doAssert unixToNativePath("./abc") == "./abc" + doAssert unixToNativePath("../abc") == "../abc" + doAssert unixToNativePath("../../abc") == "../../abc" + doAssert unixToNativePath("/abc", "a") == "/abc" + doAssert unixToNativePath("/abc/def", "a") == "/abc/def" |