summaryrefslogtreecommitdiff
path: root/test/stdpathnorm.myr
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/stdpathnorm.myr
parentde4e4e086705df3cf6ea86e92151aff077a8e768 (diff)
downloadmc-8ce47c5a9f35da34d222a5e89beb0885f8a82463.tar.gz
Add path joining and normalization functions.
Diffstat (limited to 'test/stdpathnorm.myr')
-rw-r--r--test/stdpathnorm.myr38
1 files changed, 38 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/../.."))
+}