示例#1
0
 def test_right(self):
     for key, val in SAMPLES.items():
         value = 'object:0 == ' + val
         if key == 'selector':
             d, i = self.p(value)
             self.assertEqual(d.right, Selector(0, [dlist('split', '.')]))
             self.assertEqual(i, 30)
         elif key == 'function':
             d, i = self.p(value)
             self.assertEqual(d.right, Function('max', (1, 2)))
             self.assertEqual(i, 21)
         else:
             d = self.p(value)[0].right
             v = parse_value(self.pinfo, val, 0)[0]
             self.assertEqual(d.stype, 'const')
             self.assertEqual(d.arg, v)
     self.assertRaises(ValueError, self.p, '"hello" == hello')
     self.assertRaises(ValueError, self.p, '"hello" == [min()]')
示例#2
0
 def test_left(self):
     for key, val in SAMPLES.items():
         value = val + ' bool ' + val
         if key == 'selector':
             d, i = self.p(value)
             self.assertEqual(d.left, Selector(0, [dlist('split', '.')]))
             self.assertEqual(i, 23)
             self.assertIs(d.right, None)
         elif key == 'function':
             d, i = self.p(value)
             self.assertEqual(d.left, Function('max', (1, 2)))
             self.assertEqual(i, 14)
             self.assertIs(d.right, None)
         else:
             d = self.p(value)[0].left
             v = parse_value(self.pinfo, val, 0)[0]
             self.assertEqual(d.stype, 'const')
             self.assertEqual(d.arg, v)
     self.assertEqual(self.p('hello bool'), NORES)
     self.assertRaises(ValueError, self.p, '[min()] bool')
示例#3
0
 def p(self, string):
     return parse_value({'parse': 0, 'parsers': (),
                         'deferred': self.deferred}, string, 0)[0]
示例#4
0
 def p(self, string, index=0):
     return parse_value(self.pinfo, string, index)