lean2/tests/lua/prv.lua
Leonardo de Moura 128d668f03 feat(library): add support for creating 'private/hidden' names
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-29 18:37:09 -07:00

24 lines
744 B
Lua

local env = environment()
env, n1 = add_private_name(env, "foo")
print(n1)
env, n2 = add_private_name(env, "foo")
print(n2)
env, n3 = add_private_name(env, {"foo", "bla"})
print(n3)
assert(n1 ~= n2)
assert(n1 ~= n3)
assert(n2 ~= n3)
assert(is_private_name(env, n1))
assert(is_private_name(env, n1) == name("foo"))
assert(is_private_name(env, n2) == name("foo"))
assert(is_private_name(env, n3) == name("foo", "bla"))
env:export("prv_mod.olean")
local env2 = import_modules("prv_mod")
assert(is_private_name(env2, n1) == name("foo"))
assert(is_private_name(env2, n2) == name("foo"))
assert(is_private_name(env2, n3) == name("foo", "bla"))
env2, n4 = add_private_name(env2, "foo")
print(n4)
assert(n1 ~= n4)
assert(not is_private_name(env, n4))