EvalEvaluator is called only if in root context. Added action and action_context to ExecutionContext
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import pytest
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept, PROPERTIES_TO_SERIALIZE, simplec, CMV
|
||||
from core.concept import Concept, PROPERTIES_TO_SERIALIZE, simplec, CMV, CB, CC, CV
|
||||
from evaluators.MutipleSameSuccessEvaluator import MultipleSameSuccessEvaluator
|
||||
from evaluators.PythonEvaluator import PythonEvalError
|
||||
from parsers.BaseNodeParser import SyaAssociativity
|
||||
from parsers.BnfNodeParser import Sequence, StrMatch, OrderedChoice, Optional, ConceptExpression
|
||||
|
||||
@@ -916,10 +917,34 @@ as:
|
||||
assert sheerka.isinstance(res[0].body, BuiltinConcepts.SUCCESS)
|
||||
assert sheerka.get_concepts_weights("some_prop") == {'1001': 1, '1002': 2}
|
||||
|
||||
# it now also works using the concepts names
|
||||
expression = "eval one < two"
|
||||
res = sheerka.evaluate_user_input(expression)
|
||||
assert not res[0].status
|
||||
assert res[0].status
|
||||
assert sheerka.isinstance(res[0].body, BuiltinConcepts.SUCCESS)
|
||||
assert sheerka.get_concepts_weights("some_prop") == {'1001': 1, '1002': 2}
|
||||
|
||||
def test_i_can_detect_multiple_errors_when_evaluating_a_concept(self):
|
||||
sheerka, context, foo, plus_one = self.init_concepts(
|
||||
Concept("foo", body="'string'"),
|
||||
Concept("a plus one", body="a + 1").def_var("a")
|
||||
)
|
||||
|
||||
res = sheerka.evaluate_user_input("eval foo plus one")
|
||||
|
||||
assert not res[0].status
|
||||
assert context.sheerka.isinstance(res[0].body, BuiltinConcepts.CONCEPT_EVAL_ERROR)
|
||||
assert context.sheerka.isinstance(res[0].body.body, BuiltinConcepts.TOO_MANY_ERRORS)
|
||||
|
||||
error0 = res[0].body.body.body[0]
|
||||
assert isinstance(error0, PythonEvalError)
|
||||
assert isinstance(error0.error, TypeError)
|
||||
assert error0.error.args[0] == 'can only concatenate str (not "int") to str'
|
||||
|
||||
error1 = res[0].body.body.body[1]
|
||||
assert isinstance(error1, PythonEvalError)
|
||||
assert isinstance(error1.error, TypeError)
|
||||
assert error1.error.args[0] == "unsupported operand type(s) for +: 'Concept' and 'int'"
|
||||
|
||||
|
||||
class TestSheerkaNonRegFile(TestUsingFileBasedSheerka):
|
||||
|
||||
Reference in New Issue
Block a user