Exemplo n.º 1
0
 def test_either_fails(self):
     c = char('c')
     x = char('x')
     parser = either(c, x)
     stream = Stream('i')
     with self.assertRaises(ParseFailure):
         parser(stream)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)