[Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.6.2.1, 1.6.2.2
nascheme@users.sourceforge.net
nascheme at users.sourceforge.net
Wed Oct 12 00:50:49 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9954/Lib/test
Modified Files:
Tag: ast-branch
test_peepholer.py
Log Message:
Merge changes from HEAD into test_peepholer.py.
Index: test_peepholer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -d -r1.6.2.1 -r1.6.2.2
--- test_peepholer.py 7 Jan 2005 06:59:10 -0000 1.6.2.1
+++ test_peepholer.py 11 Oct 2005 22:50:45 -0000 1.6.2.2
@@ -109,7 +109,6 @@
('a="abc" + "def"', "('abcdef')"), # check string ops
('a = 3**4', '(81)'), # binary power
('a = 3*4', '(12)'), # binary multiply
- ('a = 13/4.0', '(3.25)'), # binary divide
('a = 13//4', '(3)'), # binary floor divide
('a = 14%4', '(2)'), # binary modulo
('a = 2+3', '(5)'), # binary add
@@ -130,6 +129,29 @@
self.assert_('(2)' in asm)
self.assert_("('b')" in asm)
+ # Verify that large sequences do not result from folding
+ asm = dis_single('a="x"*1000')
+ self.assert_('(1000)' in asm)
+
+ def test_folding_of_unaryops_on_constants(self):
+ for line, elem in (
+ ('`1`', "('1')"), # unary convert
+ ('-0.5', '(-0.5)'), # unary negative
+ ('~-2', '(1)'), # unary invert
+ ):
+ asm = dis_single(line)
+ self.assert_(elem in asm, asm)
+ self.assert_('UNARY_' not in asm)
+
+ # Verify that unfoldables are skipped
+ for line, elem in (
+ ('-"abc"', "('abc')"), # unary negative
+ ('~"abc"', "('abc')"), # unary invert
+ ):
+ asm = dis_single(line)
+ self.assert_(elem in asm, asm)
+ self.assert_('UNARY_' 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