Fixed #48 : RelationalExpressionParser: Implement relational operator parser

Fixed #49 : ExpressionParser: Implement ExpressionParser
Fixed #50 : Implement ReteConditionExprVisitor
Fixed #51 : Implement PythonConditionExprVisitor
Fixed #52 : SheerkaConceptManager: I can get and set concept property
This commit is contained in:
2021-03-23 11:35:10 +01:00
parent f8e47e2b38
commit 6cda2686fb
25 changed files with 1083 additions and 978 deletions
+20 -1
View File
@@ -10,7 +10,7 @@ from sheerkarete.common import V, WME, ReteToken
from sheerkarete.conditions import Condition, NegatedCondition, AndConditions
from sheerkarete.join_node import JoinNode
from sheerkarete.negative_node import NegativeNode
from sheerkarete.network import ReteNetwork, FACT_ID
from sheerkarete.network import ReteNetwork, FACT_ID, FACT_NAME, FACT_SELF, FactObj
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
from tests.sheerkarete.RuleForTestingRete import RuleForTestingRete
@@ -247,6 +247,25 @@ class TestReteNetwork(TestUsingMemoryBasedSheerka):
assert matches[0].pnode.rules == [rule]
assert network.facts == {'f-00000': ret}
def test_i_can_add_primitive(self):
network = ReteNetwork()
rule = RuleForTestingRete(AndConditions([Condition(V("a"), FACT_NAME, "a"),
Condition(V("a"), FACT_SELF, 10),
]))
network.add_rule(rule)
network.add_obj("a", 10)
assert network.working_memory == {
WME("f-00000", "__name__", "a"),
WME("f-00000", "__self__", 10),
}
# sanity check that the WME produced match the condition
matches = list(network.matches)
assert len(matches) == 1
assert matches[0].pnode.rules == [rule]
assert network.facts == {'f-00000': FactObj(10)}
def test_i_can_distinguish_objects_with_different_value(self):
network = ReteNetwork()
rule = RuleForTestingRete(AndConditions([