summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-02-22 00:07:53 -0800
committerGitHub <noreply@github.com>2020-02-22 09:07:53 +0100
commita43583f9c8771c07436ee4175e216ab802ff6165 (patch)
treea1703be1208cd97797c8e777cb710db3fcbae302 /tests
parent1276e386fe68ab2ac359657297a1a2c570d7aefb (diff)
downloadNim-a43583f9c8771c07436ee4175e216ab802ff6165.tar.gz
relativePath("foo", "foo") is now ".", not "" (#13452)
Diffstat (limited to 'tests')
-rw-r--r--tests/js/tos.nim7
-rw-r--r--tests/stdlib/tos.nim12
-rw-r--r--tests/test_nimscript.nims3
3 files changed, 18 insertions, 4 deletions
diff --git a/tests/js/tos.nim b/tests/js/tos.nim
new file mode 100644
index 000000000..7395a0ad7
--- /dev/null
+++ b/tests/js/tos.nim
@@ -0,0 +1,7 @@
+static: doAssert defined(nodejs)
+
+import os
+
+block:
+  doAssert "./foo//./bar/".normalizedPath == "foo/bar"
+  doAssert relativePath(".//foo/bar", "foo") == "bar"
diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim
index 03fc1f1e9..02a449b8c 100644
--- a/tests/stdlib/tos.nim
+++ b/tests/stdlib/tos.nim
@@ -329,15 +329,19 @@ block ospaths:
   doAssert relativePath("/Users/me/bar/z.nim", "/Users/me", '/') == "bar/z.nim"
   doAssert relativePath("", "/users/moo", '/') == ""
   doAssert relativePath("foo", "", '/') == "foo"
-  doAssert relativePath("/foo", "/Foo", '/') == (when FileSystemCaseSensitive: "../foo" else: "")
-  doAssert relativePath("/Foo", "/foo", '/') == (when FileSystemCaseSensitive: "../Foo" else: "")
-  doAssert relativePath("/foo", "/fOO", '/') == (when FileSystemCaseSensitive: "../foo" else: "")
-  doAssert relativePath("/foO", "/foo", '/') == (when FileSystemCaseSensitive: "../foO" else: "")
+  doAssert relativePath("/foo", "/Foo", '/') == (when FileSystemCaseSensitive: "../foo" else: ".")
+  doAssert relativePath("/Foo", "/foo", '/') == (when FileSystemCaseSensitive: "../Foo" else: ".")
+  doAssert relativePath("/foo", "/fOO", '/') == (when FileSystemCaseSensitive: "../foo" else: ".")
+  doAssert relativePath("/foO", "/foo", '/') == (when FileSystemCaseSensitive: "../foO" else: ".")
 
   doAssert relativePath("foo", ".", '/') == "foo"
   doAssert relativePath(".", ".", '/') == "."
   doAssert relativePath("..", ".", '/') == ".."
 
+  doAssert relativePath("foo", "foo") == "."
+  doAssert relativePath("", "foo") == ""
+  doAssert relativePath("././/foo", "foo//./") == "."
+
   when doslikeFileSystem:
     doAssert relativePath(r"c:\foo.nim", r"C:\") == r"foo.nim"
     doAssert relativePath(r"c:\foo\bar\baz.nim", r"c:\foo") == r"bar\baz.nim"
diff --git a/tests/test_nimscript.nims b/tests/test_nimscript.nims
index 3efbb0a4c..91b23efbf 100644
--- a/tests/test_nimscript.nims
+++ b/tests/test_nimscript.nims
@@ -22,4 +22,7 @@ import unicode
 import uri
 import macros
 
+block:
+  doAssert "./foo//./bar/".normalizedPath == "foo/bar".unixToNativePath
+
 echo "Nimscript imports are successful."