Added first version of DebugManager. Implemented draft of the rule engine
This commit is contained in:
@@ -38,22 +38,26 @@ class TestBaseCustomGrammarParser(TestUsingMemoryBasedSheerka):
|
||||
|
||||
return sheerka, context, parser
|
||||
|
||||
@pytest.mark.parametrize("text, expected", [
|
||||
("when xxx yyy", {Keywords.WHEN: "when xxx yyy"}),
|
||||
("when uuu vvv print xxx yyy", {Keywords.WHEN: "when uuu vvv ", Keywords.PRINT: "print xxx yyy"}),
|
||||
("print xxx yyy when uuu vvv", {Keywords.WHEN: "when uuu vvv", Keywords.PRINT: "print xxx yyy "}),
|
||||
(" when xxx", {Keywords.WHEN: "when xxx"}),
|
||||
@pytest.mark.parametrize("text, strip_tokens, expected", [
|
||||
("when xxx yyy", False, {Keywords.WHEN: "when xxx yyy"}),
|
||||
("when uuu vvv print xxx yyy", False, {Keywords.WHEN: "when uuu vvv ", Keywords.PRINT: "print xxx yyy"}),
|
||||
("print xxx yyy when uuu vvv", False, {Keywords.WHEN: "when uuu vvv", Keywords.PRINT: "print xxx yyy "}),
|
||||
(" when xxx", False, {Keywords.WHEN: "when xxx"}),
|
||||
("when xxx yyy", True, {Keywords.WHEN: "when xxx yyy"}),
|
||||
("when uuu vvv print xxx yyy", True, {Keywords.WHEN: "when uuu vvv", Keywords.PRINT: "print xxx yyy"}),
|
||||
("print xxx yyy when uuu vvv", True, {Keywords.WHEN: "when uuu vvv", Keywords.PRINT: "print xxx yyy"}),
|
||||
(" when xxx", True, {Keywords.WHEN: "when xxx"}),
|
||||
])
|
||||
def test_i_can_get_parts(self, text, expected):
|
||||
def test_i_can_get_parts(self, text, strip_tokens, expected):
|
||||
sheerka, context, parser = self.init_parser(text)
|
||||
|
||||
res = parser.get_parts(["when", "print"])
|
||||
res = parser.get_parts(["when", "print"], strip_tokens=strip_tokens)
|
||||
self.compare_results(res, expected)
|
||||
|
||||
def test_i_can_get_parts_when_multilines(self):
|
||||
text = """when
|
||||
def func(x):
|
||||
return x+1
|
||||
\treturn x+1
|
||||
func(a)
|
||||
"""
|
||||
expected = {Keywords.WHEN: "when def func(x):\n\treturn x+1\nfunc(a)\n"}
|
||||
|
||||
Reference in New Issue
Block a user