summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_float.py
diff options
context:
space:
mode:
authorAlex Martelli <aleaxit@gmail.com>2006-08-23 20:42:02 (GMT)
committerAlex Martelli <aleaxit@gmail.com>2006-08-23 20:42:02 (GMT)
commit20362a820bd09617a33721191aa966416b03427c (patch)
treed23425e8b6a7c9d56c9fe9500bf887c5007a14ae /Lib/test/test_float.py
parent29bef0bbaae7f670e65c81173b8c1afc148aa248 (diff)
downloadcpython-20362a820bd09617a33721191aa966416b03427c.zip
cpython-20362a820bd09617a33721191aa966416b03427c.tar.gz
cpython-20362a820bd09617a33721191aa966416b03427c.tar.bz2
x**2 should about equal x*x (including for a float x such that the result is
inf) but didn't; added a test to test_float to verify that, and ignored the ERANGE value for errno in the pow operation to make the new test pass (with help from Marilyn Davis at the Google Python Sprint -- thanks!).
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r--Lib/test/test_float.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index fb47db8..d616ad9 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -99,12 +99,25 @@ class IEEEFormatTestCase(unittest.TestCase):
('<f', LE_FLOAT_NAN)]:
struct.unpack(fmt, data)
+# on an IEEE platform, "overflowing" operations produce infinity
+
+class IEEEOperationsTestCase(unittest.TestCase):
+ if float.__getformat__("double").startswith("IEEE"):
+ def test_double_infinity(self):
+ big = 4.8e159
+ pro = big*big
+ self.assertEquals(repr(pro), 'inf')
+ sqr = big**2
+ self.assertEquals(repr(sqr), 'inf')
+
def test_main():
test_support.run_unittest(
FormatFunctionsTestCase,
UnknownFormatTestCase,
- IEEEFormatTestCase)
+ IEEEFormatTestCase,
+ IEEEOperationsTestCase,
+ )
if __name__ == '__main__':
test_main()