Fixed #131 : Implement ExprToConditions

Fixed #130 : ArithmeticOperatorParser
Fixed #129 : python_wrapper : create_namespace
Fixed #128 : ExpressionParser: Cannot parse func(x) infixed concept 'xxx'
This commit is contained in:
2021-10-13 16:06:57 +02:00
parent a61a1c0d2b
commit 89e1f20975
76 changed files with 5867 additions and 3206 deletions
+22 -1
View File
@@ -7,7 +7,7 @@ from core.builtin_concepts import BuiltinConcepts
from core.builtin_helpers import evaluate_expression
from core.concept import Concept
from core.global_symbols import NotFound, NotInit, Removed
from core.tokenizer import Token, TokenKind, Tokenizer, Keywords
from core.tokenizer import Keywords, Token, TokenKind, Tokenizer
@dataclass
@@ -512,3 +512,24 @@ def test_i_can_replace_after():
with pytest.raises(KeyError):
my_list3 = ["a", "b", "c", "d"]
core.utils.replace_after(my_list3, "x", my_new_items)
def test_i_can_tokens_index():
tokens = list(Tokenizer("a b c d e"))
with pytest.raises(ValueError):
core.utils.tokens_index(tokens, None)
with pytest.raises(ValueError):
core.utils.tokens_index(tokens, [])
with pytest.raises(ValueError):
core.utils.tokens_index(tokens, list(Tokenizer("f", yield_eof=False)))
assert core.utils.tokens_index(tokens, list(Tokenizer("a", yield_eof=False))) == 0
assert core.utils.tokens_index(tokens, list(Tokenizer("b", yield_eof=False))) == 2
assert core.utils.tokens_index(tokens, list(Tokenizer("b c", yield_eof=False))) == 2
assert core.utils.tokens_index(tokens, list(Tokenizer(" ", yield_eof=False))) == 1
assert core.utils.tokens_index(tokens, list(Tokenizer(" ", yield_eof=False)), skip=2) == 5
assert core.utils.tokens_index(tokens, list(Tokenizer(" ", yield_eof=False)), start_from_end=True) == 7
assert core.utils.tokens_index(tokens, list(Tokenizer(" ", yield_eof=False)), skip=2, start_from_end=True) == 3