Fixed #29: Parsers: Implement parsing memoization

Fixed #77 : Parser: ShortTermMemoryParser should be called separately
Fixed #78 : Remove VariableNode usage
Fixed #79 : ConceptManager: Implement compile caching
Fixed #80 : SheerkaExecute : parsers_key is not correctly computed
Fixed #81 : ValidateConceptEvaluator : Validate concept's where and pre clauses right after the parsing
Fixed #82 : SheerkaIsAManager: isa() failed when the set as a body
Fixed #83 : ValidateConceptEvaluator : Support BNF and SYA Concepts
Fixed #84 : ExpressionParser: Implement the parser as a standard parser
Fixed #85 : Services: Give order to services
Fixed #86 : cannot manage smart_get_attr(the short, color)
This commit is contained in:
2021-06-07 21:14:03 +02:00
parent 1059ce25c5
commit 7dcaa9c111
92 changed files with 4263 additions and 1890 deletions
+27
View File
@@ -1,3 +1,5 @@
import pytest
from sheerkarete.common import WME, V
from sheerkarete.conditions import NotEqualsCondition, AndConditions, Condition, NegatedCondition, \
NegatedConjunctiveConditions, FilterCondition, BindCondition
@@ -27,6 +29,31 @@ class TestReteConditions(TestUsingMemoryBasedSheerka):
network.remove_wme(wme)
assert len(list(network.matches)) == 0
@pytest.mark.skip("Comparison between variables need to be implemented.")
def test_i_can_test_condition_between_variables(self):
network = ReteNetwork()
conditions = [Condition(V("x"), "__name__", "x"),
Condition(V("y"), "__name__", "y"),
Condition(V("x"), "__self__", V("y"))],
rule = RuleForTestingRete(AndConditions(conditions))
network.add_rule(rule)
assert len(list(network.matches)) == 0
wme_x = WME("x", "__self__", "10")
wme_y = WME("y", "__self__", "10")
network.add_wme(wme_x)
network.add_wme(wme_y)
matches = list(network.matches)
assert len(matches) == 1
assert matches[0].pnode.rules == [rule]
assert matches[0].token.wmes == [wme_x, wme_y]
# remove wme
network.remove_wme(wme_x)
assert len(list(network.matches)) == 0
def test_i_can_manage_not_equals_condition(self):
network = ReteNetwork()
+14
View File
@@ -88,6 +88,20 @@ class TestReteNetwork(TestUsingMemoryBasedSheerka):
"fact_name.value.body": ["sub_value"],
}
def test_i_can_update_conditions_attributes_when_value_is_a_variable(self):
network = ReteNetwork()
conditions = [Condition(V("x"), "__name__", "x"),
Condition(V("y"), "__name__", "y"),
Condition(V("x"), "__self__", V("y"))]
rule = RuleForTestingRete(AndConditions(conditions))
network.add_rule(rule)
assert network.attributes_by_id == {
"x": ["__name__", "__self__"],
"y": ["__name__", "__self__"],
}
def test_adding_obj_when_no_rule_has_no_effect(self):
network = ReteNetwork()
ret = ReturnValueConcept("test", True, "value")