summaryrefslogtreecommitdiff
path: root/tests/modules/path/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-10 00:54:46 +0800
committerruki <[email protected]>2022-03-10 00:54:46 +0800
commit01afb1c8e997a4ce98bf107393101ea4cbb7e26b (patch)
tree54181e7e2848c716db9fe5a92607ab5f40b6d352 /tests/modules/path/test.lua
parent64db618a134e8a474f4d785ee47cf04723f782ef (diff)
improve path.translate
Diffstat (limited to 'tests/modules/path/test.lua')
-rw-r--r--tests/modules/path/test.lua34
1 files changed, 17 insertions, 17 deletions
diff --git a/tests/modules/path/test.lua b/tests/modules/path/test.lua
index 8954e64a3..3df399b65 100644
--- a/tests/modules/path/test.lua
+++ b/tests/modules/path/test.lua
@@ -90,34 +90,34 @@ function test_translate(t)
t:are_equal(path.translate(""), nil)
t:are_equal(path.translate("."), ".")
t:are_equal(path.translate(".."), "..")
- t:are_equal(path.translate("././."), ".")
- t:are_equal(path.translate("../foo/..", {reduce_dot2 = true}), "..")
- t:are_equal(path.translate("../foo/bar/../..", {reduce_dot2 = true}), "..")
+ t:are_equal(path.translate("././.", {normalize = true}), ".")
+ t:are_equal(path.translate("../foo/..", {normalize = true}), "..")
+ t:are_equal(path.translate("../foo/bar/../..", {normalize = true}), "..")
if is_host("windows") then
t:are_equal(path.translate("c:"), "c:")
t:are_equal(path.translate("c:\\"), "c:")
- t:are_equal(path.translate("c:\\foo\\.\\.\\"), "c:\\foo")
t:are_equal(path.translate("c:\\foo\\\\\\"), "c:\\foo")
t:are_equal(path.translate("c:\\foo\\..\\.."), "c:\\foo\\..\\..")
- t:are_equal(path.translate("c:\\foo\\bar\\.\\..\\xyz", {reduce_dot2 = true}), "c:\\foo\\xyz")
- t:are_equal(path.translate("c:\\foo\\.\\..", {reduce_dot2 = true}), "c:")
- t:are_equal(path.translate("../..", {reduce_dot2 = true}), "..\\..")
- t:are_equal(path.translate("../foo/bar/..", {reduce_dot2 = true}), "..\\foo")
- t:are_equal(path.translate("../foo/bar/../../..", {reduce_dot2 = true}), "..\\..")
+ t:are_equal(path.translate("c:\\foo\\.\\.\\", {normalize = true}), "c:\\foo")
+ t:are_equal(path.translate("c:\\foo\\bar\\.\\..\\xyz", {normalize = true}), "c:\\foo\\xyz")
+ t:are_equal(path.translate("c:\\foo\\.\\..", {normalize = true}), "c:")
+ t:are_equal(path.translate("../..", {normalize = true}), "..\\..")
+ t:are_equal(path.translate("../foo/bar/..", {normalize = true}), "..\\foo")
+ t:are_equal(path.translate("../foo/bar/../../..", {normalize = true}), "..\\..")
else
t:are_equal(path.translate("/"), "/");
t:are_equal(path.translate("////"), "/");
- t:are_equal(path.translate("/./././"), "/");
- t:are_equal(path.translate("/foo/././"), "/foo");
t:are_equal(path.translate("/foo//////"), "/foo");
t:are_equal(path.translate("/foo/../.."), "/foo/../..");
t:are_equal(path.translate("/foo/../../"), "/foo/../..");
- t:are_equal(path.translate("/foo/bar/.//..//xyz", {reduce_dot2 = true}), "/foo/xyz");
- t:are_equal(path.translate("/foo/../..", {reduce_dot2 = true}), "/");
- t:are_equal(path.translate("/foo/bar../..", {reduce_dot2 = true}), "/foo");
- t:are_equal(path.translate("../..", {reduce_dot2 = true}), "../..");
- t:are_equal(path.translate("../foo/bar/..", {reduce_dot2 = true}), "../foo");
- t:are_equal(path.translate("../foo/bar/../../..", {reduce_dot2 = true}), "../..");
+ t:are_equal(path.translate("/foo/././", {normalize = true}), "/foo");
+ t:are_equal(path.translate("/./././", {normalize = true}), "/");
+ t:are_equal(path.translate("/foo/bar/.//..//xyz", {normalize = true}), "/foo/xyz");
+ t:are_equal(path.translate("/foo/../..", {normalize = true}), "/");
+ t:are_equal(path.translate("/foo/bar../..", {normalize = true}), "/foo");
+ t:are_equal(path.translate("../..", {normalize = true}), "../..");
+ t:are_equal(path.translate("../foo/bar/..", {normalize = true}), "../foo");
+ t:are_equal(path.translate("../foo/bar/../../..", {normalize = true}), "../..");
end
end