[Python-checkins] r64056 - python/branches/tlee-ast-optimize/Lib/test/test_peepholer.py

thomas.lee python-checkins at python.org
Mon Jun 9 16:00:44 CEST 2008


Author: thomas.lee
Date: Mon Jun  9 16:00:44 2008
New Revision: 64056

Log:
Remove some tests that are no longer relevant with the new AST optimizer in place.

Modified:
   python/branches/tlee-ast-optimize/Lib/test/test_peepholer.py

Modified: python/branches/tlee-ast-optimize/Lib/test/test_peepholer.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_peepholer.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_peepholer.py	Mon Jun  9 16:00:44 2008
@@ -18,17 +18,6 @@
 
 class TestTranforms(unittest.TestCase):
 
-    def test_unot(self):
-        # UNARY_NOT JUMP_IF_FALSE POP_TOP  -->  JUMP_IF_TRUE POP_TOP'
-        def unot(x):
-            if not x == 2:
-                del x
-        asm = disassemble(unot)
-        for elem in ('UNARY_NOT', 'JUMP_IF_FALSE'):
-            self.assert_(elem not in asm)
-        for elem in ('JUMP_IF_TRUE', 'POP_TOP'):
-            self.assert_(elem in asm)
-
     def test_elim_inversion_of_is_or_in(self):
         for line, elem in (
             ('not a is b', '(is not)',),
@@ -39,22 +28,6 @@
             asm = dis_single(line)
             self.assert_(elem in asm)
 
-    def test_none_as_constant(self):
-        # LOAD_GLOBAL None  -->  LOAD_CONST None
-        def f(x):
-            None
-            return x
-        asm = disassemble(f)
-        for elem in ('LOAD_GLOBAL',):
-            self.assert_(elem not in asm)
-        for elem in ('LOAD_CONST', '(None)'):
-            self.assert_(elem in asm)
-        def f():
-            'Adding a docstring made this test fail in Py2.5.0'
-            return None
-        self.assert_('LOAD_CONST' in disassemble(f))
-        self.assert_('LOAD_GLOBAL' not in disassemble(f))
-
     def test_while_one(self):
         # Skip over:  LOAD_CONST trueconst  JUMP_IF_FALSE xx  POP_TOP
         def f():
@@ -78,44 +51,6 @@
             self.assert_('BUILD_TUPLE' not in asm)
             self.assert_('UNPACK_TUPLE' not in asm)
 
-    def test_folding_of_tuples_of_constants(self):
-        for line, elem in (
-            ('a = 1,2,3', '((1, 2, 3))'),
-            ('("a","b","c")', "(('a', 'b', 'c'))"),
-            ('a,b,c = 1,2,3', '((1, 2, 3))'),
-            ('(None, 1, None)', '((None, 1, None))'),
-            ('((1, 2), 3, 4)', '(((1, 2), 3, 4))'),
-            ):
-            asm = dis_single(line)
-            self.assert_(elem in asm)
-            self.assert_('BUILD_TUPLE' not in asm)
-
-        # Bug 1053819:  Tuple of constants misidentified when presented with:
-        # . . . opcode_with_arg 100   unary_opcode   BUILD_TUPLE 1  . . .
-        # The following would segfault upon compilation
-        def crater():
-            (~[
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-            ],)
-
-    def test_elim_extra_return(self):
-        # RETURN LOAD_CONST None RETURN  -->  RETURN
-        def f(x):
-            return x
-        asm = disassemble(f)
-        self.assert_('LOAD_CONST' not in asm)
-        self.assert_('(None)' not in asm)
-        self.assertEqual(asm.split().count('RETURN_VALUE'), 1)
-
     def test_elim_jump_to_return(self):
         # JUMP_FORWARD to RETURN -->  RETURN
         def f(cond, true_value, false_value):


More information about the Python-checkins mailing list