[pypy-svn] r61614 - in pypy/trunk: lib-python/modified-2.5.2/test pypy/interpreter/astcompiler
laszlo at codespeak.net
laszlo at codespeak.net
Sat Feb 7 17:22:35 CET 2009
Author: laszlo
Date: Sat Feb 7 17:22:32 2009
New Revision: 61614
Added:
pypy/trunk/lib-python/modified-2.5.2/test/test_peepholer.py (contents, props changed)
- copied, changed from r61602, pypy/trunk/lib-python/2.5.2/test/test_peepholer.py
Modified:
pypy/trunk/pypy/interpreter/astcompiler/opt.py
Log:
(fijal, laszlo, mastier) Hack at test_peepholer, until it works.
Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_peepholer.py (from r61602, pypy/trunk/lib-python/2.5.2/test/test_peepholer.py)
==============================================================================
--- pypy/trunk/lib-python/2.5.2/test/test_peepholer.py (original)
+++ pypy/trunk/lib-python/modified-2.5.2/test/test_peepholer.py Sat Feb 7 17:22:32 2009
@@ -2,6 +2,7 @@
import sys
from cStringIO import StringIO
import unittest
+from test_support import check_impl_detail
def disassemble(func):
f = StringIO()
@@ -70,8 +71,8 @@
def test_pack_unpack(self):
for line, elem in (
('a, = a,', 'LOAD_CONST',),
- ('a, b = a, b', 'ROT_TWO',),
- ('a, b, c = a, b, c', 'ROT_THREE',),
+ ('x[3], x[4] = a, b', 'ROT_TWO',),
+ ('x[1], x[2], x[3] = a, b, c', 'ROT_THREE',),
):
asm = dis_single(line)
self.assert_(elem in asm)
@@ -82,9 +83,9 @@
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))'),
+ ('a,b,c = 1,2,3', ''), # empty string - we only care to check BUILD_TUPLE
+ ('x = (None, 1, None)', '((None, 1, None))'),
+ ('x = ((1, 2), 3, 4)', '(((1, 2), 3, 4))'),
):
asm = dis_single(line)
self.assert_(elem in asm)
@@ -118,13 +119,15 @@
('a = 14%4', '(2)'), # binary modulo
('a = 2+3', '(5)'), # binary add
('a = 13-4', '(9)'), # binary subtract
- ('a = (12,13)[1]', '(13)'), # binary subscr
+ ('a = (12,13)[1]#detail', '(13)'), # binary subscr
('a = 13 << 2', '(52)'), # binary lshift
('a = 13 >> 2', '(3)'), # binary rshift
('a = 13 & 7', '(5)'), # binary and
('a = 13 ^ 7', '(10)'), # binary xor
('a = 13 | 7', '(15)'), # binary or
):
+ if line.endswith('#detail') and not check_impl_detail():
+ continue
asm = dis_single(line)
self.assert_(elem in asm, asm)
self.assert_('BINARY_' not in asm)
Modified: pypy/trunk/pypy/interpreter/astcompiler/opt.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/opt.py (original)
+++ pypy/trunk/pypy/interpreter/astcompiler/opt.py Sat Feb 7 17:22:32 2009
@@ -240,9 +240,12 @@
consts_w = [None] * len(nodes)
for i in range(len(nodes)):
subnode = nodes[i]
- if not isinstance(subnode, ast.Const):
+ if isinstance(subnode, ast.Const):
+ consts_w[i] = subnode.value
+ elif isinstance(subnode, ast.Name) and subnode.varname == 'None':
+ consts_w[i] = self.space.w_None
+ else:
return node # not all constants
- consts_w[i] = subnode.value
return ast.Const(self.space.newtuple(consts_w))
def visitFor(self, node):
More information about the Pypy-commit
mailing list