Implemented FunctionParser
This commit is contained in:
@@ -88,6 +88,15 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.variables() == {"a": Property("a", expected)}
|
||||
assert evaluated.metadata.is_evaluated
|
||||
|
||||
def test_i_can_evaluate_when_the_body_is_the_name_of_the_concept(self):
|
||||
# to prove that I can distinguish from a string
|
||||
sheerka, context, concept = self.init_concepts(Concept("foo", body="'foo'"), eval_body=True, create_new=True)
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, concept)
|
||||
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == "foo"
|
||||
|
||||
def test_i_can_evaluate_metadata_using_do_not_resolve(self):
|
||||
sheerka, context, concept = self.init_concepts(Concept("foo"), eval_body=True)
|
||||
concept.compiled[ConceptParts.BODY] = DoNotResolve("do not resolve")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from core.tokenizer import Tokenizer, Token, TokenKind, LexerError, Keywords
|
||||
from core.tokenizer import Tokenizer, Token, TokenKind, LexerError
|
||||
|
||||
|
||||
def test_i_can_tokenize():
|
||||
@@ -156,19 +156,6 @@ def test_i_can_parse_numbers(text):
|
||||
assert tokens[0].value == text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text, expected", [
|
||||
("def", Keywords.DEF),
|
||||
("concept", Keywords.CONCEPT),
|
||||
("as", Keywords.AS),
|
||||
("pre", Keywords.PRE),
|
||||
("post", Keywords.POST)
|
||||
])
|
||||
def test_i_can_recognize_keywords(text, expected):
|
||||
tokens = list(Tokenizer(text))
|
||||
assert tokens[0].type == TokenKind.KEYWORD
|
||||
assert tokens[0].value == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text, expected", [
|
||||
("c:key:", ("key", None)),
|
||||
("c:key|id:", ("key", "id")),
|
||||
|
||||
Reference in New Issue
Block a user