Fixed #3: Added sheerka.resolve_rule()
Fixed #5: Refactored SheerkaComparisonManager Fixed #6: Sya parser no longer works after restart
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import pytest
|
||||
|
||||
import tests.parsers.parsers_utils
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept, CIO, ALL_ATTRIBUTES, CMV
|
||||
from core.concept import Concept, CIO, CMV
|
||||
from core.global_symbols import CONCEPT_COMPARISON_CONTEXT
|
||||
from core.sheerka.services.SheerkaExecute import ParserInput
|
||||
from core.tokenizer import Tokenizer
|
||||
@@ -10,8 +12,7 @@ from parsers.BaseNodeParser import utnode, cnode, short_cnode, UnrecognizedToken
|
||||
from parsers.PythonParser import PythonNode
|
||||
from parsers.SyaNodeParser import SyaNodeParser, SyaConceptParserHelper, SyaAssociativity, \
|
||||
NoneAssociativeSequenceError, TooManyParametersFoundError, InFixToPostFix, ParenthesisMismatchError
|
||||
|
||||
import tests.parsers.parsers_utils
|
||||
from tests.TestUsingFileBasedSheerka import TestUsingFileBasedSheerka
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
|
||||
@@ -1356,3 +1357,35 @@ class TestSyaNodeParser(TestUsingMemoryBasedSheerka):
|
||||
assert res.status
|
||||
assert context.sheerka.isinstance(wrapper, BuiltinConcepts.PARSER_RESULT)
|
||||
assert lexer_nodes == [CN(cmap["suffixed"], 0, 6, source=text)]
|
||||
|
||||
|
||||
class TestFileBaseSyaNodeParser(TestUsingFileBasedSheerka):
|
||||
def test_i_can_parse_after_restart(self):
|
||||
sheerka, context, one, two, plus = self.init_test().with_concepts("one",
|
||||
"two",
|
||||
Concept("a plus b").def_var("a").def_var("b"),
|
||||
create_new=True).unpack()
|
||||
sheerka.om.commit(context)
|
||||
parser = SyaNodeParser()
|
||||
|
||||
# sanity check
|
||||
# Remove this commented section to make sure that the nominal case still works
|
||||
# res = parser.parse(context, ParserInput("one plus two"))
|
||||
# assert res.status
|
||||
# assert sheerka.isinstance(res.body.body[0].concept, plus.key)
|
||||
|
||||
sheerka = self.new_sheerka_instance(False)
|
||||
context = self.get_context(sheerka)
|
||||
|
||||
res = parser.parse(context, ParserInput("one plus two"))
|
||||
assert res.status
|
||||
assert sheerka.isinstance(res.body.body[0].concept, plus.key)
|
||||
|
||||
# adds an ontology layer and make the test again
|
||||
sheerka.push_ontology(context, "new ontology")
|
||||
sheerka = self.new_sheerka_instance(False)
|
||||
context = self.get_context(sheerka)
|
||||
|
||||
res = parser.parse(context, ParserInput("one plus two"))
|
||||
assert res.status
|
||||
assert sheerka.isinstance(res.body.body[0].concept, plus.key)
|
||||
|
||||
Reference in New Issue
Block a user