summaryrefslogtreecommitdiff
path: root/test/stdpathnorm.myr
blob: 1e8c3d6870193a1169c5ec6d9e606594f3a36e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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/../.."))
}