lean2/tests/lua/prv.lua

26 lines
777 B
Lua
Raw Normal View History

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(hidden_to_user_name(env, n1))
assert(hidden_to_user_name(env, n1) == name("foo"))
assert(hidden_to_user_name(env, n2) == name("foo"))
assert(hidden_to_user_name(env, n3) == name("foo", "bla"))
env:export("prv_mod.olean")
local env2 = import_modules("prv_mod")
assert(hidden_to_user_name(env2, n1) == name("foo"))
assert(hidden_to_user_name(env2, n2) == name("foo"))
assert(hidden_to_user_name(env2, n3) == name("foo", "bla"))
env2, n4 = add_private_name(env2, "foo")
print(n4)
assert(n1 ~= n4)
assert(not hidden_to_user_name(env, n4))