]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/test/double_const.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / double_const.py
CommitLineData
4710c53d 1from test.test_support import TestFailed\r
2\r
3# A test for SF bug 422177: manifest float constants varied way too much in\r
4# precision depending on whether Python was loading a module for the first\r
5# time, or reloading it from a precompiled .pyc. The "expected" failure\r
6# mode is that when test_import imports this after all .pyc files have been\r
7# erased, it passes, but when test_import imports this from\r
8# double_const.pyc, it fails. This indicates a woeful loss of precision in\r
9# the marshal format for doubles. It's also possible that repr() doesn't\r
10# produce enough digits to get reasonable precision for this box.\r
11\r
12PI = 3.14159265358979324\r
13TWOPI = 6.28318530717958648\r
14\r
15PI_str = "3.14159265358979324"\r
16TWOPI_str = "6.28318530717958648"\r
17\r
18# Verify that the double x is within a few bits of eval(x_str).\r
19def check_ok(x, x_str):\r
20 assert x > 0.0\r
21 x2 = eval(x_str)\r
22 assert x2 > 0.0\r
23 diff = abs(x - x2)\r
24 # If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger\r
25 # than 0.375 ULP, so adding diff/8 to x2 should have no effect.\r
26 if x2 + (diff / 8.) != x2:\r
27 raise TestFailed("Manifest const %s lost too much precision " % x_str)\r
28\r
29check_ok(PI, PI_str)\r
30check_ok(TWOPI, TWOPI_str)\r