Fixed some misbehaviours regarding question() + added #import functionality when restoring
This commit is contained in:
@@ -1061,26 +1061,27 @@ as:
|
||||
"def concept number",
|
||||
"set_isa(one, number)",
|
||||
"def concept q from q ? as question(q)",
|
||||
"set_auto_eval(q)",
|
||||
"def concept is_a from x is a y as isa(x,y) pre in_context(BuiltinConcepts.EVAL_QUESTION_REQUESTED)",
|
||||
"set_is_greater_than(BuiltinConcepts.PRECEDENCE, c:is_a:, c:q:)"
|
||||
"set_is_greater_than(BuiltinConcepts.PRECEDENCE, c:is_a:, c:q:)",
|
||||
]
|
||||
|
||||
sheerka = self.init_scenario(init)
|
||||
res = sheerka.evaluate_user_input("one is a number ?") # automatically evaluated
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].body
|
||||
assert res[0].body == True # the body MUST be a boolean
|
||||
|
||||
res = sheerka.evaluate_user_input("foo is a number ?") # automatically evaluated
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert not res[0].body
|
||||
assert res[0].body == False # the body MUST be a boolean
|
||||
|
||||
# Sanity, when there is only one 'is a' concept. It's chosen regardless of the PRE condition
|
||||
# x is a y is supposed to be a question. It cannot be used if not in a context of a question
|
||||
res = sheerka.evaluate_user_input("one is a number")
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].body
|
||||
assert not res[0].status
|
||||
assert sheerka.isinstance(res[0].body, BuiltinConcepts.CONDITION_FAILED)
|
||||
|
||||
def test_i_can_evaluate_source_code_with_concept(self):
|
||||
init = [
|
||||
|
||||
Reference in New Issue
Block a user