test suite test resolver
implicit import ideal • machine • resources
class test store
public test store(string path prefix, boolean is current)
super(path prefix, is current, is current)
override boolean exists(string scheme, immutable list[string] path)
return false
override string read string(string scheme, immutable list[string] path)
return "test"
override void write string(string scheme, immutable list[string] path, string new value)
pass
override void make catalog(string scheme, immutable list[string] path)
pass
override readonly set[string] or null read catalog(string scheme, immutable list[string] path) pure
return missing • instance
implement protected string default scheme() => resource util • FILE SCHEME
static CURRENT : test store • new(resource util • CURRENT CATALOG, true) • top()
static ROOT : test store • new(resource util • ROOT CATALOG, false) • top()
test case test file catalogs()
assert CURRENT • get id() • to string == "."
assert ROOT • get id() • to string == "/"
test case test simple resolve()
foo : "foo"
assert CURRENT • resolve(foo) • to string == "foo"
assert ROOT • resolve(foo) • to string == "/foo"
test case test resolve extension()
bar : "bar"
assert CURRENT • resolve(bar, html) • to string == "bar.html"
assert ROOT • resolve(bar, html) • to string == "/bar.html"
test case test sub catalogs()
dog : cat • resolve("dog")
assert dog • to string == "dog"
cat2 : dog • access catalog()
assert cat2 • get id() • to string == "dog"
dog2 : cat2 • resolve("Yoshka")
assert dog2 • to string == "dog/Yoshka"
test case test root subdirs()
cat : ROOT
dog : cat • resolve("dog")
assert dog • to string == "/dog"
cat2 : dog • access catalog()
assert cat2 • get id() • to string == "/dog"
dog2 : cat2 • resolve("Yoshka")
assert dog2 • to string == "/dog/Yoshka"
test case test multiple subdirs()
var foo : ROOT
var bar : foo • resolve("bar")
assert bar • to string == "/bar"
foo = bar • access catalog()
assert foo • get id() • to string == "/bar"
bar = foo • resolve("baz")
assert bar • to string == "/bar/baz"
foo = bar • access catalog()
bar = foo • resolve("quux")
assert bar • to string == "/bar/baz/quux"
foo = bar • access catalog()
bar = foo • resolve("")
assert bar • to string == "/bar/baz/quux"
bar = foo • resolve("./././.")
assert bar • to string == "/bar/baz/quux"
test case test more subdir ops()
var foo : CURRENT
var bar : foo • resolve("foo/bar/././baz")
assert "foo/bar/baz" == bar • to string
foo = bar • access catalog()
bar = foo • resolve("..")
assert "foo/bar" == bar • to string
foo = bar • access catalog()
bar = foo • resolve("../..")
assert "." == bar • to string
foo = bar • access catalog()
bar = foo • resolve("..")
assert "." == bar • to string
test case test parent catalog()
var bar : foo • resolve("foo/bar/././baz")
assert "foo/bar/baz" == bar • to string
bar = bar • parent()
assert "foo/bar" == bar • to string
bar = bar • parent()
assert "foo" == bar • to string
bar = bar • parent()
assert "." == bar • to string
bar = bar • parent()
assert "." == bar • to string
test case test filesystem()
directory name : "runtime/resources"
file set : hash set[string] • new()
file set • add all(["base_extension.i", "base_resource_catalog.i", "base_resource_identifier.i", "base_resource_store.i", "make_catalog_option.i", "resource_store.i", "resource_util.i", "resources.i", "test_resolver.i"])
directory : filesystem • CURRENT CATALOG • resolve(directory name) • access catalog()
content : directory • content
assert content is_not null
for (file : content • elements)
name : file • key
assert file • value • to string == (directory name ++ "/" ++ name)
assert file set • contains(name)
file set • remove(name)
return file set • is empty