[Subversion] / PEAK-Rules / test_rules.py  

Diff of /PEAK-Rules/test_rules.py

Parent Directory | Revision Log

version 2759, Sat Apr 4 23:56:09 2015 UTC version 2760, Sat Apr 4 23:59:08 2015 UTC
Line 617 
Line 617 
         from peak.rules.indexing import TypeIndex, to_bits          from peak.rules.indexing import TypeIndex, to_bits
         from peak.rules.predicates import class_node          from peak.rules.predicates import class_node
         from peak.rules.criteria import Class, Conjunction          from peak.rules.criteria import Class, Conjunction
           try:
         from types import InstanceType          from types import InstanceType
         ind = TypeIndex(self, 'expr')          except ImportError:
               class InstanceType(object): pass
               class a(InstanceType): pass
               class b(InstanceType): pass
           else:
         class a: pass          class a: pass
         class b: pass          class b: pass
           ind = TypeIndex(self, 'expr')
         class c(a,b): pass          class c(a,b): pass
         class x(a,b,object): pass          class x(a,b,object): pass
   
         ind.add_case(0, Class(InstanceType))          ind.add_case(0, Class(InstanceType))
         ind.add_case(1, Conjunction([Class(a), Class(b), Class(c,False)]))          ind.add_case(1, Conjunction([Class(a), Class(b), Class(c,False)]))
         ind.add_case(2, Class(object))          ind.add_case(2, Class(object))
Line 644 
Line 649 
             (c, to_bits([0,2,3,4,5])),              (c, to_bits([0,2,3,4,5])),
             (x, to_bits([1,2,3,4,5]))              (x, to_bits([1,2,3,4,5]))
         ]          ]
         for k, v in data:          if issubclass(a, InstanceType):
             self.assertEqual(lookup(k), v)              data.pop()
           for k, v in data: self.assertEqual(lookup(k), v)
         self.assertEqual(cache, dict(data))          self.assertEqual(cache, dict(data))
   
   
   
   
   
   
   
 class DecompilationTests(unittest.TestCase):  class DecompilationTests(unittest.TestCase):
   
     def setUp(self):      def setUp(self):
Line 681 
Line 681 
         from peak.util.assembler import Pass, Getattr, Local          from peak.util.assembler import Pass, Getattr, Local
         self.check(Pass, '')          self.check(Pass, '')
         self.check(Getattr(Local('a'), 'b'), 'a.b')          self.check(Getattr(Local('a'), 'b'), 'a.b')
         self.roundtrip('not -+~`a`')          self.roundtrip(no_backquotes('not -+~`a`'))
         self.roundtrip('a+b-c*d/e%f**g//h')          self.roundtrip('a+b-c*d/e%f**g//h')
         self.roundtrip('a and b or not c')          self.roundtrip('a and b or not c')
         self.roundtrip('~a|b^c&d<<e>>f')          self.roundtrip('~a|b^c&d<<e>>f')
Line 710 
Line 710 
     def test_paren_precedence(self):      def test_paren_precedence(self):
         self.roundtrip('(1).__class__')          self.roundtrip('(1).__class__')
         self.roundtrip('1.2.__class__')          self.roundtrip('1.2.__class__')
         self.roundtrip('`(a, b)`')          self.roundtrip(no_backquotes('`(a, b)`'))
         self.roundtrip('`a,b`', '`(a, b)`')          self.roundtrip(no_backquotes('`a,b`'), no_backquotes('`(a, b)`'))
         self.roundtrip('(a, [b, c])')          self.roundtrip('(a, [b, c])')
         self.roundtrip('a,b', '(a, b)')          self.roundtrip('a,b', '(a, b)')
         self.roundtrip('a+b*c')          self.roundtrip('a+b*c')
Line 795 
Line 795 
 except NameError:  except NameError:
     from functools import reduce      from functools import reduce
   
   def no_backquotes(s):
       if sys.version >= "3":
           return s.replace('`','')
       return s
   
   
   


Generate output suitable for use with a patch program
Legend:
Removed from v.2759  
changed lines
  Added in v.2760

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help