summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-08-14 10:40:32 -0400
committerOri Bernstein <ori@eigenstate.org>2014-08-14 10:40:32 -0400
commit8ce47c5a9f35da34d222a5e89beb0885f8a82463 (patch)
tree07e3588b748521241e6430a24ea3115dbc4fb943 /test
parentde4e4e086705df3cf6ea86e92151aff077a8e768 (diff)
downloadmc-8ce47c5a9f35da34d222a5e89beb0885f8a82463.tar.gz
Add path joining and normalization functions.
Diffstat (limited to 'test')
-rw-r--r--test/stdpathnorm.myr38
-rw-r--r--test/tests1
2 files changed, 39 insertions, 0 deletions
diff --git a/test/stdpathnorm.myr b/test/stdpathnorm.myr
new file mode 100644
index 0000000..1e8c3d6
--- /dev/null
+++ b/test/stdpathnorm.myr
@@ -0,0 +1,38 @@
+use std
+
+const main = {
+ /* untouched */
+ std.put("%s\n", std.pathnorm("foo"))
+ std.put("%s\n", std.pathnorm("foo/bar"))
+ std.put("%s\n", std.pathnorm("/foo/bar"))
+ std.put("%s\n", std.pathnorm("."))
+
+ /* empty path becomes "." */
+ std.put("%s\n", std.pathnorm("."))
+
+ /* delete //, trailing / */
+ std.put("%s\n", std.pathnorm("foo/"))
+ std.put("%s\n", std.pathnorm("foo//bar/baz"))
+ std.put("%s\n", std.pathnorm("//foo//bar/"))
+
+ /* delete '.' */
+ std.put("%s\n", std.pathnorm("foo/./bar"))
+ std.put("%s\n", std.pathnorm("/foo/bar/."))
+ std.put("%s\n", std.pathnorm("./foo/bar/."))
+
+ /* elide '..' */
+ std.put("%s\n", std.pathnorm("/../foo/bar"))
+ std.put("%s\n", std.pathnorm("../../foo/bar"))
+ std.put("%s\n", std.pathnorm("foo/bar/.."))
+ std.put("%s\n", std.pathnorm("foo/bar/../.."))
+ std.put("%s\n", std.pathnorm("foo/../bar/../.."))
+ std.put("%s\n", std.pathnorm("/foo/../bar/../.."))
+
+ /* mix all of the above */
+ std.put("%s\n", std.pathnorm("/../foo//bar"))
+ std.put("%s\n", std.pathnorm("..//../foo/bar"))
+ std.put("%s\n", std.pathnorm("foo//./bar/.."))
+ std.put("%s\n", std.pathnorm("foo/bar/.././.."))
+ std.put("%s\n", std.pathnorm("//foo/../bar/../.."))
+ std.put("%s\n", std.pathnorm("foo/../bar/../.."))
+}
diff --git a/test/tests b/test/tests
index e20d30b..963f5a0 100644
--- a/test/tests
+++ b/test/tests
@@ -129,6 +129,7 @@ B strfind C
B strjoin C
B stdslcp C
B stdfmtpad C
+B stdpathnorm C
B bigint C
B exporttrait
# B local-labels E 10 ## BUGGERED