예제 #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)
예제 #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)
예제 #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)