summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-07-04 19:25:53 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-07-04 19:25:53 +0200
commit86a7054c88a03c2f13bf15191fc681311aa1cc62 (patch)
treeec576ed3d127816a21981db19b9562d3b8b24aeb /tests/stdlib
parente45502390280c13c7336f5b907babb42fd4f5435 (diff)
parentab47a870bce94cb33c66f2b27ecb1c62f48ae783 (diff)
downloadNim-86a7054c88a03c2f13bf15191fc681311aa1cc62.tar.gz
Merge branch 'devel' into araq-devel
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tospaths.nim41
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"