Introduced ParserInput
This commit is contained in:
@@ -2,6 +2,7 @@ import pytest
|
||||
|
||||
from core.builtin_concepts import ReturnValueConcept, ParserResultConcept, BuiltinConcepts
|
||||
from core.concept import Concept, DEFINITION_TYPE_DEF
|
||||
from core.sheerka.services.SheerkaExecute import ParserInput
|
||||
from evaluators.PythonEvaluator import PythonEvaluator
|
||||
from parsers.PythonParser import PythonNode, PythonParser
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
@@ -31,7 +32,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
])
|
||||
def test_i_can_eval(self, text, expected):
|
||||
context = self.get_context()
|
||||
parsed = PythonParser().parse(context, text)
|
||||
parsed = PythonParser().parse(context, ParserInput(text))
|
||||
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
@@ -40,7 +41,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
|
||||
def test_i_can_eval_using_context(self):
|
||||
context = self.get_context()
|
||||
parsed = PythonParser().parse(context, "test_using_context('value for param1', 10)")
|
||||
parsed = PythonParser().parse(context, ParserInput("test_using_context('value for param1', 10)"))
|
||||
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
@@ -49,7 +50,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
|
||||
def test_i_can_eval_using_context_when_self_is_not_sheerka(self):
|
||||
sheerka, context = self.init_concepts()
|
||||
parsed = PythonParser().parse(context, "create_new_concept(Concept('foo'))")
|
||||
parsed = PythonParser().parse(context, ParserInput("create_new_concept(Concept('foo'))"))
|
||||
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
@@ -66,7 +67,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
context = self.get_context()
|
||||
context.sheerka.add_in_cache(Concept("foo"))
|
||||
|
||||
parsed = PythonParser().parse(context, "foo")
|
||||
parsed = PythonParser().parse(context, ParserInput("foo"))
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
assert not evaluated.status
|
||||
@@ -80,7 +81,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
context = self.get_context()
|
||||
context.sheerka.add_in_cache(Concept("foo", body="1"))
|
||||
|
||||
parsed = PythonParser().parse(context, "foo + 2")
|
||||
parsed = PythonParser().parse(context, ParserInput("foo + 2"))
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
assert evaluated.status
|
||||
@@ -94,7 +95,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
context = self.get_context()
|
||||
context.sheerka.add_in_cache(Concept("foo"))
|
||||
|
||||
parsed = PythonParser().parse(context, "def a(b):\n return b\na(c:foo:)")
|
||||
parsed = PythonParser().parse(context, ParserInput("def a(b):\n return b\na(c:foo:)"))
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
assert evaluated.status
|
||||
@@ -108,7 +109,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
context = self.get_context()
|
||||
context.sheerka.add_in_cache(Concept("foo", body="2"))
|
||||
|
||||
parsed = PythonParser().parse(context, "def a(b):\n return b\na(foo)")
|
||||
parsed = PythonParser().parse(context, ParserInput("def a(b):\n return b\na(foo)"))
|
||||
evaluated = PythonEvaluator().eval(context, parsed)
|
||||
|
||||
assert evaluated.status
|
||||
@@ -118,7 +119,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
context = self.get_context()
|
||||
context.sheerka.add_in_cache(Concept("foo", body="2"))
|
||||
|
||||
parsed = PythonParser().parse(context, "get_concept_name(c:foo:)")
|
||||
parsed = PythonParser().parse(context, ParserInput("get_concept_name(c:foo:)"))
|
||||
python_evaluator = PythonEvaluator()
|
||||
python_evaluator.locals["get_concept_name"] = get_concept_name
|
||||
evaluated = python_evaluator.eval(context, parsed)
|
||||
@@ -127,7 +128,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.value == "foo"
|
||||
|
||||
# sanity, does not work otherwise
|
||||
parsed = PythonParser().parse(context, "get_concept_name(foo)")
|
||||
parsed = PythonParser().parse(context, ParserInput("get_concept_name(foo)"))
|
||||
python_evaluator = PythonEvaluator()
|
||||
python_evaluator.locals["get_concept_name"] = get_concept_name
|
||||
evaluated = python_evaluator.eval(context, parsed)
|
||||
@@ -141,7 +142,7 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
self.from_def_concept("mult", "a mult b", ["a", "b"]),
|
||||
)
|
||||
|
||||
parsed = PythonParser().parse(context, "is_greater_than(BuiltinConcepts.PRECEDENCE, mult, plus)")
|
||||
parsed = PythonParser().parse(context, ParserInput("is_greater_than(BuiltinConcepts.PRECEDENCE, mult, plus)"))
|
||||
python_evaluator = PythonEvaluator()
|
||||
|
||||
evaluated = python_evaluator.eval(context, parsed)
|
||||
|
||||
Reference in New Issue
Block a user