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:
@@ -3,6 +3,7 @@ import pytest
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept
|
||||
from core.sheerka.services.SheerkaExecute import ParserInput
|
||||
from parsers.BaseNodeParser import SourceCodeWithConceptNode
|
||||
from parsers.BaseParser import ErrorSink
|
||||
from parsers.FunctionParser import FunctionParser
|
||||
from parsers.PythonParser import PythonErrorNode
|
||||
@@ -192,6 +193,17 @@ class TestFunctionParser(TestUsingMemoryBasedSheerka):
|
||||
assert expression.python_node is not None
|
||||
assert expression.return_value is not None
|
||||
|
||||
def test_i_can_parse_when_the_parameter_is_a_dynamic_concept(self):
|
||||
sheerka, context, parser = self.init_parser()
|
||||
|
||||
text = "func(ones)"
|
||||
res = parser.parse(context, ParserInput(text))
|
||||
|
||||
assert res.status
|
||||
assert isinstance(res.body.body, SourceCodeWithConceptNode)
|
||||
assert res.body.body.python_node.source == 'func(__C__ones__1001___PLURAL__C__)'
|
||||
assert "__C__ones__1001___PLURAL__C__" in res.body.body.python_node.objects
|
||||
|
||||
@pytest.mark.parametrize("text, expected_error_type", [
|
||||
("one", BuiltinConcepts.NOT_FOR_ME), # no function found
|
||||
("$*!", BuiltinConcepts.NOT_FOR_ME), # no function found
|
||||
|
||||
@@ -229,11 +229,13 @@ class TestSequenceNodeParser(TestUsingMemoryBasedSheerka):
|
||||
sheerka, context, parser = self.init_parser(concepts_map)
|
||||
|
||||
res = parser.parse(context, ParserInput("a special concept"))
|
||||
assert res.status
|
||||
lexer_nodes = res.body.body
|
||||
expected_array = compute_expected_array(concepts_map, "a special concept", ["a special concept"])
|
||||
compare_with_test_object(lexer_nodes, expected_array)
|
||||
|
||||
res = parser.parse(context, ParserInput("isa"))
|
||||
assert res.status
|
||||
lexer_nodes = res.body.body
|
||||
expected_array = compute_expected_array(concepts_map, "isa", ["isa"])
|
||||
compare_with_test_object(lexer_nodes, expected_array)
|
||||
@@ -442,3 +444,22 @@ class TestSequenceNodeParser(TestUsingMemoryBasedSheerka):
|
||||
for node in res.body.body:
|
||||
if hasattr(node, "concept"):
|
||||
assert node.concept.get_hints().use_copy
|
||||
|
||||
def test_i_can_parse_plural(self):
|
||||
concepts_map = {
|
||||
"boy": Concept("boy"),
|
||||
}
|
||||
|
||||
sheerka, context, parser = self.init_parser(concepts_map)
|
||||
boy = concepts_map['boy']
|
||||
|
||||
res = parser.parse(context, ParserInput("boys"))
|
||||
assert res.status
|
||||
lexer_nodes = res.body.body
|
||||
assert len(lexer_nodes) == 1
|
||||
|
||||
concept_found = lexer_nodes[0].concept
|
||||
assert concept_found.id == f"{boy.id}-{BuiltinConcepts.PLURAL}"
|
||||
assert concept_found.name == "boys"
|
||||
assert concept_found.key == "boys"
|
||||
assert concept_found.get_prop(BuiltinConcepts.PLURAL) == boy
|
||||
|
||||
Reference in New Issue
Block a user