lean2/tests/lua/context1.lua
Leonardo de Moura 3e1fd06903 refactor(kernel/expr): remove 'null' expression, and operator bool for expression
After this commit, a value of type 'expr' cannot be a reference to nullptr.
This commit also fixes several bugs due to the use of 'null' expressions.

TODO: do the same for kernel objects, sexprs, etc.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-07 23:21:10 -08:00

25 lines
650 B
Lua

c = context()
assert(c:is_empty())
print(c)
e = context_entry("x", Const("N"))
assert(e:get_name() == name("x"))
assert(e:get_domain() == Const("N"))
assert(not e:get_body())
print(e:get_body())
c = context(c, e)
print(c)
assert(not c:is_empty())
c = context(c, "y", Const("M"))
assert(#c == 2)
assert(c:size() == 2)
e, c1 = lookup(c, 0)
assert(c1:size() == 1)
assert(e:get_name() == name("y"))
c = context(c, "z", Const("N"), Const("a"))
print(c)
check_error(function() lookup(c, 10) end)
assert(lookup(c, 0):get_body() == Const("a"))
assert(not is_context_entry(c))
assert(is_context(c))
assert(is_context_entry(e))
assert(not is_context_entry(c))