Working on #98 : Persist attribute value when global_truth is set to true

This commit is contained in:
2021-08-03 11:26:57 +02:00
parent e69745adc8
commit c798c2c570
22 changed files with 496 additions and 106 deletions
+19 -2
View File
@@ -94,6 +94,7 @@ as:
expected.get_metadata().id = "1001"
expected.get_metadata().desc = None
expected.get_metadata().variables = [("a", None), ("b", None)]
expected.get_metadata().parameters = ["a", "b"]
expected.init_key()
sheerka = self.get_sheerka(cache_only=False)
@@ -134,6 +135,7 @@ as:
res = sheerka.evaluate_user_input("def concept a xx b as a plus b")
expected = Concept(name="a xx b", body="a plus b").def_var("a").def_var("b").init_key()
expected.get_metadata().id = "1001"
expected.get_metadata().parameters = ["a", "b"]
assert len(res) == 1
assert res[0].status
@@ -1392,17 +1394,32 @@ as:
"set_isa(color, adjective)",
"def concept what is the x of y pre is_question() as smart_get_attr(y, x)",
"def concept qualify x from bnf adjective x as set_attr(x, c:adjective:, adjective) ret x",
"eval a red short",
]
sheerka = self.init_scenario(init, global_truth=True)
res = sheerka.evaluate_user_input("eval a red short")
res = sheerka.evaluate_user_input("what is the color of the short ?")
assert len(res) == 1
assert res[0].status
assert res[0].value == "red"
res = sheerka.evaluate_user_input("eval a blue short")
sheerka.evaluate_user_input("eval a blue short")
res = sheerka.evaluate_user_input("what is the color of the short ?")
assert len(res) == 1
assert res[0].status
assert res[0].value == "blue"
def test_i_can_access_a_concept_after_a_global_set_attr(self):
init = [
"def concept foo",
"def concept color",
"def concept red",
"global_truth(set_attr(foo, color, red))"
]
sheerka = self.init_scenario(init)
res = sheerka.evaluate_user_input("inspect(foo)")
assert len(res) == 1
assert res[0].status