def test_either_fails(self): c = char('c') x = char('x') parser = either(c, x) stream = Stream('i') with self.assertRaises(ParseFailure): parser(stream)
def test_either_ok_two(self): c = char('c') x = char('x') parser = either(c, x) stream = Stream('xirotanibmoc') out, stream = parser(stream) self.assertEqual(out, 'x') self.assertEqual(stream.position, 1)
def test_either_ok_one(self): c = char('c') x = char('x') parser = either(c, x) stream = Stream('combinatorix') out, stream = parser(stream) self.assertEqual(out, 'c') self.assertEqual(stream.position, 1)