MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_halfway_cases

Method test_halfway_cases

Lib/test/test_strtod.py:150–174  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

148
149 @unittest.skip("TODO: RUSTPYTHON; fails on debug mode, flaky in release mode")
150 def test_halfway_cases(self):
151 # test halfway cases for the round-half-to-even rule
152 for i in range(100 * TEST_SIZE):
153 # bit pattern for a random finite positive (or +0.0) float
154 bits = random.randrange(2047*2**52)
155
156 # convert bit pattern to a number of the form m * 2**e
157 e, m = divmod(bits, 2**52)
158 if e:
159 m, e = m + 2**52, e - 1
160 e -= 1074
161
162 # add 0.5 ulps
163 m, e = 2*m + 1, e - 1
164
165 # convert to a decimal string
166 if e >= 0:
167 digits = m << e
168 exponent = 0
169 else:
170 # m * 2**e = (m * 5**-e) * 10**e
171 digits = m * 5**-e
172 exponent = e
173 s = '{}e{}'.format(digits, exponent)
174 self.check_strtod(s)
175
176 @unittest.expectedFailure # TODO: RUSTPYTHON
177 def test_boundaries(self):

Callers

nothing calls this directly

Calls 4

check_strtodMethod · 0.95
randrangeMethod · 0.80
divmodFunction · 0.50
formatMethod · 0.45

Tested by

no test coverage detected