[Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.2,
1.3
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Sep 22 20:44:42 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4038/Lib/test
Modified Files:
test_peepholer.py
Log Message:
SF patch #1031667: Fold tuples of constants into a single constant
Example:
>>> import dis
>>> dis.dis(compile('1,2,3', '', 'eval'))
0 0 LOAD_CONST 3 ((1, 2, 3))
3 RETURN_VALUE
Index: test_peepholer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_peepholer.py 26 Aug 2004 05:23:19 -0000 1.2
+++ test_peepholer.py 22 Sep 2004 18:44:08 -0000 1.3
@@ -64,15 +64,25 @@
def test_pack_unpack(self):
for line, elem in (
- ('a, = 1,', 'LOAD_CONST',),
- ('a, b = 1, 2', 'ROT_TWO',),
- ('a, b, c = 1, 2, 3', 'ROT_THREE',),
+ ('a, = a,', 'LOAD_CONST',),
+ ('a, b = a, b', 'ROT_TWO',),
+ ('a, b, c = a, b, c', 'ROT_THREE',),
):
asm = dis_single(line)
self.assert_(elem in asm)
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))',),
+ ):
+ asm = dis_single(line)
+ self.assert_(elem in asm)
+ self.assert_('BUILD_TUPLE' not in asm)
+
def test_elim_extra_return(self):
# RETURN LOAD_CONST None RETURN --> RETURN
def f(x):
More information about the Python-checkins
mailing list