annotate Lib/test/double_const.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 226ba34bd998
children 9c930a32cebb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24442
226ba34bd998 Complete the absolute import patch for the test suite. All relative
Barry Warsaw <barry@python.org>
parents: 17699
diff changeset
1 from test.test_support import TestFailed
17699
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
2
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
3 # A test for SF bug 422177: manifest float constants varied way too much in
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
4 # precision depending on whether Python was loading a module for the first
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
5 # time, or reloading it from a precompiled .pyc. The "expected" failure
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
6 # mode is that when test_import imports this after all .pyc files have been
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
7 # erased, it passes, but when test_import imports this from
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
8 # double_const.pyc, it fails. This indicates a woeful loss of precision in
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
9 # the marshal format for doubles. It's also possible that repr() doesn't
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
10 # produce enough digits to get reasonable precision for this box.
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
11
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
12 PI = 3.14159265358979324
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
13 TWOPI = 6.28318530717958648
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
14
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
15 PI_str = "3.14159265358979324"
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
16 TWOPI_str = "6.28318530717958648"
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
17
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
18 # Verify that the double x is within a few bits of eval(x_str).
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
19 def check_ok(x, x_str):
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
20 assert x > 0.0
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
21 x2 = eval(x_str)
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
22 assert x2 > 0.0
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
23 diff = abs(x - x2)
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
24 # If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
25 # than 0.375 ULP, so adding diff/8 to x2 should have no effect.
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
26 if x2 + (diff / 8.) != x2:
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
27 raise TestFailed("Manifest const %s lost too much precision " % x_str)
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
28
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
29 check_ok(PI, PI_str)
54623626da4e This is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
30 check_ok(TWOPI, TWOPI_str)