shithub: mc

ref: ad008b9e79bfae6db3cf4049ac441f9696f2c459
dir: /test/stdpathnorm.myr/

View raw version
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/../.."))
}