diff options
author | Raymond Hettinger <python@rcn.com> | 2011-03-23 12:53:32 -0700 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-03-23 12:53:32 -0700 |
commit | 41da10e62cfa2fee9c651d0d613a6f6998bf6f2c (patch) | |
tree | 50897c71d9ac469c30cb0d0e8fa8817e3623f567 /Lib/test/test_peepholer.py | |
parent | 2ebea41d315bb42a6d6983137bf5fdb01d3f1a95 (diff) | |
parent | 5839b9635cd582a5a2660605a48bddafab44aa06 (diff) | |
download | cpython-git-41da10e62cfa2fee9c651d0d613a6f6998bf6f2c.tar.gz |
Merge
Diffstat (limited to 'Lib/test/test_peepholer.py')
-rw-r--r-- | Lib/test/test_peepholer.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index f73565eb46..78de90923e 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -3,6 +3,7 @@ import re import sys from io import StringIO import unittest +from math import copysign def disassemble(func): f = StringIO() @@ -207,6 +208,9 @@ class TestTranforms(unittest.TestCase): def test_folding_of_unaryops_on_constants(self): for line, elem in ( ('-0.5', '(-0.5)'), # unary negative + ('-0.0', '(-0.0)'), # -0.0 + ('-(1.0-1.0)','(-0.0)'), # -0.0 after folding + ('-0', '(0)'), # -0 ('~-2', '(1)'), # unary invert ('+1', '(1)'), # unary positive ): @@ -214,6 +218,13 @@ class TestTranforms(unittest.TestCase): self.assertIn(elem, asm, asm) self.assertNotIn('UNARY_', asm) + # Check that -0.0 works after marshaling + def negzero(): + return -(1.0-1.0) + + self.assertNotIn('UNARY_', disassemble(negzero)) + self.assertTrue(copysign(1.0, negzero()) < 0) + # Verify that unfoldables are skipped for line, elem in ( ('-"abc"', "('abc')"), # unary negative |