Beispiel #1
0
 def test_long_commands(self):
     assert CommandStrategy.tokenize('rule "~[a rule] tested"') == \
            ["rule", '"~[a rule] tested"']
     assert \
         CommandStrategy.tokenize(
             'set-modifier alias "something else" casegen "True"\t'
         ) == [
             "set-modifier", "alias",
             '"something else"', "casegen", '"True"'
         ]
Beispiel #2
0
 def test_short_commands(self):
     assert CommandStrategy.tokenize("exit") == ["exit"]
     assert CommandStrategy.tokenize("stats  ") == ["stats"]
     assert CommandStrategy.tokenize("NOT-command") == ["NOT-command"]
     assert CommandStrategy.tokenize("NOT COMMAND") == ["NOT", "COMMAND"]
     assert CommandStrategy.tokenize('word "a name"') == [
         "word", '"a name"'
     ]
     assert CommandStrategy.tokenize(' open "quote a') == [
         "open", '"quote a'
     ]
     assert CommandStrategy.tokenize("regex /with space/i") == [
         "regex", "/with space/i"
     ]
Beispiel #3
0
 def test_escapement(self):
     assert CommandStrategy.tokenize('test "escaped \\" was here"') == \
            ["test", '"escaped \\" was here"']
Beispiel #4
0
 def test_empty(self):
     assert CommandStrategy.tokenize("") == []
Beispiel #5
0
 def to_tokens(text):
     return CommandStrategy.tokenize(text)