def test_many(self): rule = easyparse.many(easyparse.PatternRule('a')) self.assertEqual((True, easyparse.Ignored), rule.parse('')) for i in range(1, 5): self.assertEqual((True, ['a']), rule.parse('a ' * i)) for i in range(1, 5): self.assertEqual((True, ['a'] * i), rule.parse('a' * i))
def test_many(self): rule = easyparse.many(easyparse.PatternRule('a')) self.assertEqual((True, easyparse.Ignored), rule.parse('')) for i in range(1,5): self.assertEqual((True, ['a']), rule.parse('a ' * i)) for i in range(1,5): self.assertEqual((True, ['a'] * i), rule.parse('a' * i))
def test_parse_large_stack_with_many(self): rule = easyparse.many(easyparse.parse('a')) ok, result = rule.parse('a' * 1000) self.assertTrue(ok) self.assertEqual(['a'] * 1000, result)