Refactored Concept class for better separation of metadata, compiled and values
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from core.builtin_concepts import BuiltinConcepts, ReturnValueConcept
|
||||
from core.builtin_concepts import BuiltinConcepts, ReturnValueConcept, UserInputConcept
|
||||
from core.concept import Concept
|
||||
from core.sheerka import Sheerka, ExecutionContext
|
||||
from evaluators.PrepareEvalEvaluator import PrepareEvalEvaluator
|
||||
@@ -13,18 +13,21 @@ def get_context():
|
||||
return ExecutionContext("test", Event(), sheerka)
|
||||
|
||||
|
||||
r = ReturnValueConcept
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ret_val, expected", [
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body="eval 1 + 1")), True),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body=" eval 1 + 1")), True),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body="eval")), False),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body="1+1")), False),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body="")), False),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body="eval ")), False),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body=[])), False),
|
||||
(ReturnValueConcept("some_name", True, Concept("foo")), False),
|
||||
(ReturnValueConcept("some_name", True, "not a concept"), False),
|
||||
(ReturnValueConcept("some_name", False, Concept(key=BuiltinConcepts.USER_INPUT, body="eval 1 + 1")), False),
|
||||
(ReturnValueConcept("some_name", False, Concept(key=BuiltinConcepts.USER_INPUT, body=" eval 1 + 1")), False),
|
||||
(r("name", True, UserInputConcept("eval 1 + 1")), True),
|
||||
(r("name", True, UserInputConcept(" eval 1 + 1")), True),
|
||||
(r("name", True, UserInputConcept("eval")), False),
|
||||
(r("name", True, UserInputConcept("1+1")), False),
|
||||
(r("name", True, UserInputConcept("")), False),
|
||||
(r("name", True, UserInputConcept("eval ")), False),
|
||||
(r("name", True, UserInputConcept([])), False),
|
||||
(r("name", True, Concept("foo")), False),
|
||||
(r("name", True, "not a concept"), False),
|
||||
(r("name", False, UserInputConcept("eval 1 + 1")), False),
|
||||
(r("name", False, UserInputConcept(" eval 1 + 1")), False),
|
||||
])
|
||||
def test_i_can_match(ret_val, expected):
|
||||
context = get_context()
|
||||
@@ -32,8 +35,8 @@ def test_i_can_match(ret_val, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ret_val, expected", [
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body="eval 1 + 1")), "1 + 1"),
|
||||
(ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.USER_INPUT, body=" eval 1 + 1")), "1 + 1"),
|
||||
(r("name", True, UserInputConcept("eval 1 + 1")), "1 + 1"),
|
||||
(r("name", True, UserInputConcept(" eval 1 + 1")), "1 + 1"),
|
||||
])
|
||||
def test_i_can_eval(ret_val, expected):
|
||||
context = get_context()
|
||||
|
||||
Reference in New Issue
Block a user