Fixed #101 : Implement PLURIAL
Fixed #103 : Implement PlurialNodeParser Fixed #104 : Implement dynamic concept Fixed #107 : PrepareEvalxxxEvaluator: context hints are lost on a second evaluation
This commit is contained in:
@@ -518,6 +518,29 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
evaluated = sheerka.evaluate_concept(self.get_context(sheerka, False, False), concept)
|
||||
assert evaluated.key == concept.key
|
||||
|
||||
def test_i_can_evaluate_context_hint_multiple_times(self):
|
||||
"""
|
||||
Previous behaviour (that we want to change)
|
||||
When def concept foo as global_truth(xxx) pre yyy
|
||||
the context hint for the global truth is set during the initialisation of the ast
|
||||
if the body is computed straight away it's ok,
|
||||
But if the concept is evaluated a second time, the asts is not computed again, so the context hint is not set
|
||||
:return:
|
||||
"""
|
||||
sheerka, context, foo = self.init_concepts(
|
||||
Concept("foo", body="global_truth(in_context(BuiltinConcepts.EVAL_GLOBAL_TRUTH_REQUESTED))")
|
||||
)
|
||||
|
||||
foo_instance = sheerka.new("foo")
|
||||
evaluated = sheerka.evaluate_concept(context, foo_instance, eval_body=False)
|
||||
|
||||
assert ConceptParts.BODY in evaluated.get_compiled()
|
||||
assert evaluated.body == NotInit
|
||||
assert not evaluated.get_hints().is_evaluated
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, foo_instance, eval_body=True) # evaluate the body this time
|
||||
assert isinstance(evaluated.body, bool) and evaluated.body
|
||||
|
||||
def test_i_can_apply_intermediate_where_condition_using_python(self):
|
||||
sheerka, context, one_1, one_str, plus = self.init_concepts(
|
||||
Concept("one", body="1"),
|
||||
@@ -818,10 +841,14 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
(Concept("foo"), False, []),
|
||||
(Concept("foo", pre="pre", post="post", ret="ret", where="where"), False, ["#pre#", "#post#"]),
|
||||
(Concept("foo", pre="pr", post="p", ret="r", where="w"), True,
|
||||
["#pre#", "#ret#", "#post#", "variables", "#body#"]),
|
||||
["#pre#", "variables", "#body#", "#ret#", "#post#"]),
|
||||
|
||||
(Concept("foo", pre="pre", body="body"), False, ["#pre#"]),
|
||||
(Concept("foo", pre="pre", body="body"), True, ["#pre#", "variables", "#body#"]),
|
||||
(Concept("foo", pre="a").def_var("a"), False, ["variables", "#pre#"]),
|
||||
(Concept("foo", pre="self"), False, ["#body#", "#pre#"]),
|
||||
(Concept("foo", pre="self + a").def_var("a"), False, ["variables", "#body#", "#pre#"]),
|
||||
|
||||
(Concept("foo", pre="self + a", ret="ret").def_var("a"), False, ["variables", "#body#", "#pre#"]),
|
||||
(Concept("foo", pre="self + a", ret="ret").def_var("a"), True, ["variables", "#body#", "#pre#", "#ret#"]),
|
||||
(Concept("foo", body="body"), False, [])
|
||||
|
||||
Reference in New Issue
Block a user