def test_fails_to_parse_front(self): e = self.assertParseFailure( combinators.between(primitives.error({"error!"}), primitives.match(lambda c: c == "l"), primitives.match(lambda c: c == "e")), "hello") self.assertEqual({"error!"}, e.expected)
def test_fails_to_parse_back(self): e = self.assertSimpleParseFailure( combinators.between(primitives.match(lambda c: c == "h"), primitives.error({"error!"}), primitives.match(lambda c: c == "e")), "hello") self.assertEqual("l", e.value) self.assertEqual(list("lo"), list(e.it)) self.assertEqual({"error!"}, e.expected)
def test_parses(self): self.assertParse( combinators.between(primitives.match(lambda c: c == "h"), primitives.match(lambda c: c == "l"), primitives.match(lambda c: c == "e")), "e", "lo", "hello")