585f3adde1
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
23 lines
1.3 KiB
Lua
23 lines
1.3 KiB
Lua
local env = environment()
|
|
env = env:begin_namespace_scope("foo")
|
|
assert(env:get_namespace() == name("foo"))
|
|
env = add_decl(env, mk_var_decl(name(env:get_namespace(), "nat"), Type))
|
|
env = add_decl(env, mk_var_decl(name(env:get_namespace(), "int"), Type))
|
|
env = env:begin_namespace_scope("bar")
|
|
assert(env:get_namespace() == name("foo", "bar"))
|
|
assert(env:namespace_find("int"):name() == name("foo", "int"))
|
|
assert(env:namespace_find("nat"):name() == name("foo", "nat"))
|
|
env = add_decl(env, mk_var_decl(name(env:get_namespace(), "int"), Type))
|
|
assert(env:namespace_find("int"):name() == name("foo", "bar", "int"))
|
|
assert(env:get_name_in_namespace(name("foo", "bar", "int")) == name("int"))
|
|
assert(env:get_name_in_namespace(name("foo", "int")) == name("foo", "int")) -- it was shadowed by foo.bar.int
|
|
assert(env:get_name_in_namespace(name("foo", "nat")) == name("nat"))
|
|
env = env:end_scope()
|
|
assert(env:get_namespace() == name("foo"))
|
|
assert(env:get_name_in_namespace(name("foo", "bar", "int")) == name("bar", "int"))
|
|
assert(env:get_name_in_namespace(name("foo", "nat")) == name("nat"))
|
|
env = env:end_scope()
|
|
assert(env:get_name_in_namespace(name("foo", "bar", "int")) == name("foo", "bar", "int"))
|
|
assert(env:get_name_in_namespace(name("foo", "nat")) == name("foo", "nat"))
|
|
check_error(function() env = env:end_scope() end)
|
|
assert(env:get_namespace() == name())
|