Example #1
0
 def test_no_flatten_and(self):
     matcher = And('a', Join(And('b', 'c')))
     matcher.config.clear().flatten()
     parser = matcher.get_parse()
     text = str(parser.matcher)
     assert text == "And(Literal, Transform)", text
     result = parser('abcd')
     assert result == ['a', 'bc'], result
Example #2
0
 def test_flatten_and_transform(self):
     matcher = Join(And('a', And('b', 'c')))
     matcher.config.clear().flatten()
     parser = matcher.get_parse()
     text = sub('<.*>', '<>', str(parser.matcher))
     assert text == "Transform(And, TransformationWrapper(<>))", text
     result = parser('abcd')
     assert result == ['abc'], result
Example #3
0
 def test_replace(self):
     #basicConfig(level=DEBUG)
     matcher = And('a', 'b')
     matcher.config.clear().direct_eval()
     parser = matcher.get_parse()
     text = str(parser.matcher)
     assert "AndNoTrampoline(Literal, Literal)" == text, text
     result = parser('ab')
     assert result == ['a', 'b'], result