shithub: mc

ref: 658dd280c40c5a6edb110e1170013e8479fe2bd0
dir: /lib/std/test/dirname.myr/

View raw version
use std

const main = {
	eq(std.dirname("foo/bar"), "foo")
	eq(std.dirname("/foo/bar"), "/foo")
	eq(std.dirname("/foo/bar/"), "/foo")
	eq(std.dirname("/bar/"), "/")
	eq(std.dirname("/"), "/")
	eq(std.dirname("///"), "/")

	eq(std.basename("foo/bar"), "bar")
	eq(std.basename("/foo/bar"), "bar")
	eq(std.basename("/foo/bar/"), "bar")
	eq(std.basename("/bar/"), "bar")
	eq(std.basename("/"), "")
	eq(std.basename("///"), "")
}

const eq = {a, e
	if !std.sleq(e, a)
		std.fatal("expected '{}', got '{}'\n", e, a)
	;;
}