MCPcopy Index your code
hub / github.com/python/cpython / test_boundaries

Function test_boundaries

Modules/_decimal/tests/randfloat.py:81–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79 yield s
80
81def test_boundaries():
82 # boundaries expressed as triples (n, e, u), where
83 # n*10**e is an approximation to the boundary value and
84 # u*10**e is 1ulp
85 boundaries = [
86 (10000000000000000000, -19, 1110), # a power of 2 boundary (1.0)
87 (17976931348623159077, 289, 1995), # overflow boundary (2.**1024)
88 (22250738585072013831, -327, 4941), # normal/subnormal (2.**-1022)
89 (0, -327, 4941), # zero
90 ]
91 for n, e, u in boundaries:
92 for j in range(1000):
93 for i in range(TEST_SIZE):
94 digits = n + random.randrange(-3*u, 3*u)
95 exponent = e
96 s = '{}e{}'.format(digits, exponent)
97 yield s
98 n *= 10
99 u *= 10
100 e -= 1
101
102def test_underflow_boundary():
103 # test values close to 2**-1075, the underflow boundary; similar

Callers 1

randfloat.pyFile · 0.85

Calls 2

randrangeMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…