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
+4 -4
View File
@@ -32,7 +32,7 @@ name : foo
key : foo
definition: None
type : None
hash : 16f7fbb8bc509b8c652edaf3d0c0457d15a37f0a862fbe03fa357b0c77249c46
hash : 632c9ac7f3a08777918aeee4bb53712caedc634a863ae39a641f69055ae2e238
body : 1
where : None
pre : None
@@ -45,7 +45,7 @@ name : foo
key : foo
definition: None
type : None
hash : 7036cd5ffa9294d2e1dc9bf9c9bbe2783ace5cf7f423bfce9b28c8d33c0d1d0c
hash : 23a1a8bc5966982471aa19b8452e22d414a55d704431866e198570913d47fd7d
body : 2
where : None
pre : None
@@ -71,7 +71,7 @@ name : foo
key : foo
definition: None
type : None
hash : 16f7fbb8bc509b8c652edaf3d0c0457d15a37f0a862fbe03fa357b0c77249c46
hash : 632c9ac7f3a08777918aeee4bb53712caedc634a863ae39a641f69055ae2e238
body : 1
where : None
pre : None
@@ -84,7 +84,7 @@ name : foo
key : foo
definition: None
type : None
hash : e8dd1af1b6bc0eca0fb4a87a6fabb16655caa4b7a6ea9dbbd1f887757e6caf89
hash : 60e442c59940a2616a3783d2e34f428f4a5ae456a88539bba9a5e87cf77060a6
body : 2
where : True
pre : None