Implemented a first and basic version of a Rete rule engine
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import ast
|
||||
import pytest
|
||||
|
||||
import core.builtin_helpers
|
||||
import pytest
|
||||
from core.builtin_concepts import ReturnValueConcept, BuiltinConcepts
|
||||
from core.concept import Concept
|
||||
|
||||
from core.global_symbols import NotInit
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
|
||||
@@ -157,6 +156,32 @@ class TestBuiltinHelpers(TestUsingMemoryBasedSheerka):
|
||||
res = core.builtin_helpers.resolve_ambiguity(context, concepts)
|
||||
assert [c.name for c in res] == expected
|
||||
|
||||
@pytest.mark.parametrize("pre, expected", [
|
||||
("x and y", False),
|
||||
("is_question()", True),
|
||||
(" is_question ( ) ", True),
|
||||
("context.in_context(BuiltinConcepts.EVAL_QUESTION_REQUESTED)", True),
|
||||
(" context . in_context ( BuiltinConcepts . EVAL_QUESTION_REQUESTED ) ", True),
|
||||
(None, False),
|
||||
("", False),
|
||||
(NotInit, False),
|
||||
("is _ question()", False),
|
||||
("is_ question()", False),
|
||||
("is _question()", False),
|
||||
("context.in _context(BuiltinConcepts.EVAL_QUESTION_REQUESTED)", False),
|
||||
("not is_question()", False),
|
||||
("not context.in_context(BuiltinConcepts.EVAL_QUESTION_REQUESTED)", False),
|
||||
("is_question() and True", True),
|
||||
("is_question() and False", True), # don't care about the second argument if it is not related to question
|
||||
("is_question() and xxx", True), # don't care about the second argument if it is not related to question
|
||||
("is_question() and not is_question()", False), # error ?
|
||||
("is_question() and not context.in_context(BuiltinConcepts.EVAL_QUESTION_REQUESTED)", False), # error ?
|
||||
])
|
||||
def test_is_a_question(self, pre, expected):
|
||||
sheerka, context = self.init_test().unpack()
|
||||
concept = Concept("foo", pre=pre)
|
||||
assert core.builtin_helpers.is_a_question(context, concept) == expected
|
||||
|
||||
# @pytest.mark.parametrize("return_values", [
|
||||
# None,
|
||||
# []
|
||||
|
||||
Reference in New Issue
Block a user