blob: 24202be7f62ebce145a3bfcc2c181bc3af371e85 [file] [log] [blame]
Michael W. Hudsonba283e22005-05-27 15:23:20 +00001
2import unittest, struct
Christian Heimes827b35c2007-12-10 22:19:17 +00003import os
Eric Smith0923d1d2009-04-16 20:16:10 +00004import sys
Benjamin Petersonee8712c2008-05-20 21:35:26 +00005from test import support
Christian Heimes53876d92008-04-19 00:31:39 +00006import math
Mark Dickinson65fe25e2008-07-16 11:30:51 +00007from math import isinf, isnan, copysign, ldexp
Christian Heimes53876d92008-04-19 00:31:39 +00008import operator
Amaury Forgeot d'Arc7e958d12008-09-06 21:03:22 +00009import random, fractions
Michael W. Hudsonba283e22005-05-27 15:23:20 +000010
Christian Heimes53876d92008-04-19 00:31:39 +000011INF = float("inf")
12NAN = float("nan")
Christian Heimes99170a52007-12-19 02:07:34 +000013
Eric Smith0923d1d2009-04-16 20:16:10 +000014#locate file with float format test values
15test_dir = os.path.dirname(__file__) or os.curdir
16format_testfile = os.path.join(test_dir, 'formatfloat_testcases.txt')
17
Christian Heimes81ee3ef2008-05-04 22:42:01 +000018class GeneralFloatCases(unittest.TestCase):
19
20 def test_float(self):
21 self.assertEqual(float(3.14), 3.14)
22 self.assertEqual(float(314), 314.0)
23 self.assertEqual(float(" 3.14 "), 3.14)
Amaury Forgeot d'Arc7e958d12008-09-06 21:03:22 +000024 self.assertEqual(float(b" 3.14 "), 3.14)
Christian Heimes81ee3ef2008-05-04 22:42:01 +000025 self.assertRaises(ValueError, float, " 0x3.1 ")
26 self.assertRaises(ValueError, float, " -0x3.p-1 ")
27 self.assertRaises(ValueError, float, " +0x3.p-1 ")
28 self.assertRaises(ValueError, float, "++3.14")
29 self.assertRaises(ValueError, float, "+-3.14")
30 self.assertRaises(ValueError, float, "-+3.14")
31 self.assertRaises(ValueError, float, "--3.14")
Eric Smith0923d1d2009-04-16 20:16:10 +000032 self.assertRaises(ValueError, float, ".nan")
33 self.assertRaises(ValueError, float, "+.inf")
34 self.assertRaises(ValueError, float, ".")
35 self.assertRaises(ValueError, float, "-.")
Amaury Forgeot d'Arc7e958d12008-09-06 21:03:22 +000036 self.assertEqual(float(b" \u0663.\u0661\u0664 ".decode('raw-unicode-escape')), 3.14)
Christian Heimes81ee3ef2008-05-04 22:42:01 +000037
Benjamin Petersonee8712c2008-05-20 21:35:26 +000038 @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
Christian Heimes81ee3ef2008-05-04 22:42:01 +000039 def test_float_with_comma(self):
40 # set locale to something that doesn't use '.' for the decimal point
41 # float must not accept the locale specific decimal point but
42 # it still has to accept the normal python syntac
43 import locale
44 if not locale.localeconv()['decimal_point'] == ',':
45 return
46
47 self.assertEqual(float(" 3.14 "), 3.14)
48 self.assertEqual(float("+3.14 "), 3.14)
49 self.assertEqual(float("-3.14 "), -3.14)
50 self.assertEqual(float(".14 "), .14)
51 self.assertEqual(float("3. "), 3.0)
52 self.assertEqual(float("3.e3 "), 3000.0)
53 self.assertEqual(float("3.2e3 "), 3200.0)
54 self.assertEqual(float("2.5e-1 "), 0.25)
55 self.assertEqual(float("5e-1"), 0.5)
56 self.assertRaises(ValueError, float, " 3,14 ")
57 self.assertRaises(ValueError, float, " +3,14 ")
58 self.assertRaises(ValueError, float, " -3,14 ")
59 self.assertRaises(ValueError, float, " 0x3.1 ")
60 self.assertRaises(ValueError, float, " -0x3.p-1 ")
61 self.assertRaises(ValueError, float, " +0x3.p-1 ")
62 self.assertEqual(float(" 25.e-1 "), 2.5)
Benjamin Petersond43029b2008-09-06 23:33:21 +000063 self.assertEqual(support.fcmp(float(" .25e-1 "), .025), 0)
Christian Heimes81ee3ef2008-05-04 22:42:01 +000064
65 def test_floatconversion(self):
66 # Make sure that calls to __float__() work properly
67 class Foo0:
68 def __float__(self):
69 return 42.
70
71 class Foo1(object):
72 def __float__(self):
73 return 42.
74
75 class Foo2(float):
76 def __float__(self):
77 return 42.
78
79 class Foo3(float):
80 def __new__(cls, value=0.):
81 return float.__new__(cls, 2*value)
82
83 def __float__(self):
84 return self
85
86 class Foo4(float):
87 def __float__(self):
88 return 42
89
Benjamin Peterson2808d3c2009-04-15 21:34:27 +000090 # Issue 5759: __float__ not called on str subclasses (though it is on
91 # unicode subclasses).
92 class FooStr(str):
93 def __float__(self):
94 return float(str(self)) + 1
95
Christian Heimes81ee3ef2008-05-04 22:42:01 +000096 self.assertAlmostEqual(float(Foo0()), 42.)
97 self.assertAlmostEqual(float(Foo1()), 42.)
98 self.assertAlmostEqual(float(Foo2()), 42.)
99 self.assertAlmostEqual(float(Foo3(21)), 42.)
100 self.assertRaises(TypeError, float, Foo4(42))
Benjamin Peterson2808d3c2009-04-15 21:34:27 +0000101 self.assertAlmostEqual(float(FooStr('8')), 9.)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000102
103 def test_floatasratio(self):
104 for f, ratio in [
105 (0.875, (7, 8)),
106 (-0.875, (-7, 8)),
107 (0.0, (0, 1)),
108 (11.5, (23, 2)),
109 ]:
110 self.assertEqual(f.as_integer_ratio(), ratio)
111
112 for i in range(10000):
113 f = random.random()
114 f *= 10 ** random.randint(-100, 100)
115 n, d = f.as_integer_ratio()
116 self.assertEqual(float(n).__truediv__(d), f)
117
118 R = fractions.Fraction
119 self.assertEqual(R(0, 1),
120 R(*float(0.0).as_integer_ratio()))
121 self.assertEqual(R(5, 2),
122 R(*float(2.5).as_integer_ratio()))
123 self.assertEqual(R(1, 2),
124 R(*float(0.5).as_integer_ratio()))
125 self.assertEqual(R(4728779608739021, 2251799813685248),
126 R(*float(2.1).as_integer_ratio()))
127 self.assertEqual(R(-4728779608739021, 2251799813685248),
128 R(*float(-2.1).as_integer_ratio()))
129 self.assertEqual(R(-2100, 1),
130 R(*float(-2100.0).as_integer_ratio()))
131
132 self.assertRaises(OverflowError, float('inf').as_integer_ratio)
133 self.assertRaises(OverflowError, float('-inf').as_integer_ratio)
134 self.assertRaises(ValueError, float('nan').as_integer_ratio)
135
Mark Dickinson4a1f5932008-11-12 23:23:36 +0000136 def test_float_containment(self):
137 floats = (INF, -INF, 0.0, 1.0, NAN)
138 for f in floats:
139 self.assert_(f in [f], "'%r' not in []" % f)
140 self.assert_(f in (f,), "'%r' not in ()" % f)
141 self.assert_(f in {f}, "'%r' not in set()" % f)
142 self.assert_(f in {f: None}, "'%r' not in {}" % f)
143 self.assertEqual([f].count(f), 1, "[].count('%r') != 1" % f)
144 self.assert_(f in floats, "'%r' not in container" % f)
145
146 for f in floats:
147 # nonidentical containers, same type, same contents
148 self.assert_([f] == [f], "[%r] != [%r]" % (f, f))
149 self.assert_((f,) == (f,), "(%r,) != (%r,)" % (f, f))
150 self.assert_({f} == {f}, "{%r} != {%r}" % (f, f))
151 self.assert_({f : None} == {f: None}, "{%r : None} != "
152 "{%r : None}" % (f, f))
153
154 # identical containers
155 l, t, s, d = [f], (f,), {f}, {f: None}
156 self.assert_(l == l, "[%r] not equal to itself" % f)
157 self.assert_(t == t, "(%r,) not equal to itself" % f)
158 self.assert_(s == s, "{%r} not equal to itself" % f)
159 self.assert_(d == d, "{%r : None} not equal to itself" % f)
160
161
162
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000163class FormatFunctionsTestCase(unittest.TestCase):
164
165 def setUp(self):
166 self.save_formats = {'double':float.__getformat__('double'),
167 'float':float.__getformat__('float')}
168
169 def tearDown(self):
170 float.__setformat__('double', self.save_formats['double'])
171 float.__setformat__('float', self.save_formats['float'])
172
173 def test_getformat(self):
174 self.assert_(float.__getformat__('double') in
175 ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
176 self.assert_(float.__getformat__('float') in
177 ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
178 self.assertRaises(ValueError, float.__getformat__, 'chicken')
179 self.assertRaises(TypeError, float.__getformat__, 1)
180
181 def test_setformat(self):
182 for t in 'double', 'float':
183 float.__setformat__(t, 'unknown')
184 if self.save_formats[t] == 'IEEE, big-endian':
185 self.assertRaises(ValueError, float.__setformat__,
186 t, 'IEEE, little-endian')
187 elif self.save_formats[t] == 'IEEE, little-endian':
188 self.assertRaises(ValueError, float.__setformat__,
189 t, 'IEEE, big-endian')
190 else:
191 self.assertRaises(ValueError, float.__setformat__,
192 t, 'IEEE, big-endian')
193 self.assertRaises(ValueError, float.__setformat__,
194 t, 'IEEE, little-endian')
195 self.assertRaises(ValueError, float.__setformat__,
196 t, 'chicken')
197 self.assertRaises(ValueError, float.__setformat__,
198 'chicken', 'unknown')
199
Guido van Rossum2be161d2007-05-15 20:43:51 +0000200BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00'
Guido van Rossum254348e2007-11-21 19:29:53 +0000201LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF))
Guido van Rossum2be161d2007-05-15 20:43:51 +0000202BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00'
Guido van Rossum254348e2007-11-21 19:29:53 +0000203LE_DOUBLE_NAN = bytes(reversed(BE_DOUBLE_NAN))
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000204
Guido van Rossum2be161d2007-05-15 20:43:51 +0000205BE_FLOAT_INF = b'\x7f\x80\x00\x00'
Guido van Rossum254348e2007-11-21 19:29:53 +0000206LE_FLOAT_INF = bytes(reversed(BE_FLOAT_INF))
Guido van Rossum2be161d2007-05-15 20:43:51 +0000207BE_FLOAT_NAN = b'\x7f\xc0\x00\x00'
Guido van Rossum254348e2007-11-21 19:29:53 +0000208LE_FLOAT_NAN = bytes(reversed(BE_FLOAT_NAN))
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000209
210# on non-IEEE platforms, attempting to unpack a bit pattern
211# representing an infinity or a NaN should raise an exception.
212
213class UnknownFormatTestCase(unittest.TestCase):
214 def setUp(self):
215 self.save_formats = {'double':float.__getformat__('double'),
216 'float':float.__getformat__('float')}
217 float.__setformat__('double', 'unknown')
218 float.__setformat__('float', 'unknown')
Tim Peters5d36a552005-06-03 22:40:27 +0000219
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000220 def tearDown(self):
221 float.__setformat__('double', self.save_formats['double'])
222 float.__setformat__('float', self.save_formats['float'])
223
224 def test_double_specials_dont_unpack(self):
225 for fmt, data in [('>d', BE_DOUBLE_INF),
226 ('>d', BE_DOUBLE_NAN),
227 ('<d', LE_DOUBLE_INF),
228 ('<d', LE_DOUBLE_NAN)]:
229 self.assertRaises(ValueError, struct.unpack, fmt, data)
230
231 def test_float_specials_dont_unpack(self):
232 for fmt, data in [('>f', BE_FLOAT_INF),
233 ('>f', BE_FLOAT_NAN),
234 ('<f', LE_FLOAT_INF),
235 ('<f', LE_FLOAT_NAN)]:
236 self.assertRaises(ValueError, struct.unpack, fmt, data)
237
238
239# on an IEEE platform, all we guarantee is that bit patterns
240# representing infinities or NaNs do not raise an exception; all else
241# is accident (today).
Guido van Rossum04110fb2007-08-24 16:32:05 +0000242# let's also try to guarantee that -0.0 and 0.0 don't get confused.
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000243
244class IEEEFormatTestCase(unittest.TestCase):
245 if float.__getformat__("double").startswith("IEEE"):
246 def test_double_specials_do_unpack(self):
247 for fmt, data in [('>d', BE_DOUBLE_INF),
248 ('>d', BE_DOUBLE_NAN),
249 ('<d', LE_DOUBLE_INF),
250 ('<d', LE_DOUBLE_NAN)]:
251 struct.unpack(fmt, data)
252
253 if float.__getformat__("float").startswith("IEEE"):
254 def test_float_specials_do_unpack(self):
255 for fmt, data in [('>f', BE_FLOAT_INF),
256 ('>f', BE_FLOAT_NAN),
257 ('<f', LE_FLOAT_INF),
258 ('<f', LE_FLOAT_NAN)]:
259 struct.unpack(fmt, data)
260
Guido van Rossum04110fb2007-08-24 16:32:05 +0000261 if float.__getformat__("double").startswith("IEEE"):
262 def test_negative_zero(self):
263 import math
264 def pos_pos():
265 return 0.0, math.atan2(0.0, -1)
266 def pos_neg():
267 return 0.0, math.atan2(-0.0, -1)
268 def neg_pos():
269 return -0.0, math.atan2(0.0, -1)
270 def neg_neg():
271 return -0.0, math.atan2(-0.0, -1)
272 self.assertEquals(pos_pos(), neg_pos())
273 self.assertEquals(pos_neg(), neg_neg())
274
Eric Smith8c663262007-08-25 02:26:07 +0000275class FormatTestCase(unittest.TestCase):
Eric Smith11fe3e02007-08-31 01:33:06 +0000276 def test_format(self):
Eric Smith8c663262007-08-25 02:26:07 +0000277 # these should be rewritten to use both format(x, spec) and
278 # x.__format__(spec)
279
280 self.assertEqual(format(0.0, 'f'), '0.000000')
281
282 # the default is 'g', except for empty format spec
283 self.assertEqual(format(0.0, ''), '0.0')
284 self.assertEqual(format(0.01, ''), '0.01')
285 self.assertEqual(format(0.01, 'g'), '0.01')
286
Eric Smith8c663262007-08-25 02:26:07 +0000287
288 self.assertEqual(format(1.0, 'f'), '1.000000')
Eric Smith8c663262007-08-25 02:26:07 +0000289
290 self.assertEqual(format(-1.0, 'f'), '-1.000000')
Eric Smith8c663262007-08-25 02:26:07 +0000291
292 self.assertEqual(format( 1.0, ' f'), ' 1.000000')
293 self.assertEqual(format(-1.0, ' f'), '-1.000000')
294 self.assertEqual(format( 1.0, '+f'), '+1.000000')
295 self.assertEqual(format(-1.0, '+f'), '-1.000000')
296
297 # % formatting
298 self.assertEqual(format(-1.0, '%'), '-100.000000%')
299
300 # conversion to string should fail
301 self.assertRaises(ValueError, format, 3.0, "s")
302
Eric Smith7b69c6c2008-01-27 21:07:59 +0000303 # other format specifiers shouldn't work on floats,
304 # in particular int specifiers
305 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
306 [chr(x) for x in range(ord('A'), ord('Z')+1)]):
307 if not format_spec in 'eEfFgGn%':
308 self.assertRaises(ValueError, format, 0.0, format_spec)
309 self.assertRaises(ValueError, format, 1.0, format_spec)
310 self.assertRaises(ValueError, format, -1.0, format_spec)
311 self.assertRaises(ValueError, format, 1e100, format_spec)
312 self.assertRaises(ValueError, format, -1e100, format_spec)
313 self.assertRaises(ValueError, format, 1e-100, format_spec)
314 self.assertRaises(ValueError, format, -1e-100, format_spec)
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000315
Eric Smith0923d1d2009-04-16 20:16:10 +0000316 @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
317 "test requires IEEE 754 doubles")
318 def test_format_testfile(self):
319 for line in open(format_testfile):
320 if line.startswith('--'):
321 continue
322 line = line.strip()
323 if not line:
324 continue
325
326 lhs, rhs = map(str.strip, line.split('->'))
327 fmt, arg = lhs.split()
328 self.assertEqual(fmt % float(arg), rhs)
329 self.assertEqual(fmt % -float(arg), '-' + rhs)
330
Mark Dickinson7efad9e2009-04-17 20:59:58 +0000331class ReprTestCase(unittest.TestCase):
332 def test_repr(self):
333 floats_file = open(os.path.join(os.path.split(__file__)[0],
334 'floating_points.txt'))
335 for line in floats_file:
336 line = line.strip()
337 if not line or line.startswith('#'):
338 continue
339 v = eval(line)
340 self.assertEqual(v, eval(repr(v)))
341 floats_file.close()
342
Eric Smith0923d1d2009-04-16 20:16:10 +0000343 @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
344 "applies only when using short float repr style")
345 def test_short_repr(self):
346 # test short float repr introduced in Python 3.1. One aspect
347 # of this repr is that we get some degree of str -> float ->
348 # str roundtripping. In particular, for any numeric string
349 # containing 15 or fewer significant digits, those exact same
350 # digits (modulo trailing zeros) should appear in the output.
351 # No more repr(0.03) -> "0.029999999999999999"!
352
353 test_strings = [
354 # output always includes *either* a decimal point and at
355 # least one digit after that point, or an exponent.
356 '0.0',
357 '1.0',
358 '0.01',
359 '0.02',
360 '0.03',
361 '0.04',
362 '0.05',
363 '1.23456789',
364 '10.0',
365 '100.0',
366 # values >= 1e16 get an exponent...
367 '1000000000000000.0',
368 '9999999999999990.0',
369 '1e+16',
370 '1e+17',
371 # ... and so do values < 1e-4
372 '0.001',
373 '0.001001',
374 '0.00010000000000001',
375 '0.0001',
376 '9.999999999999e-05',
377 '1e-05',
378 # values designed to provoke failure if the FPU rounding
379 # precision isn't set correctly
380 '8.72293771110361e+25',
381 '7.47005307342313e+26',
382 '2.86438000439698e+28',
383 '8.89142905246179e+28',
384 '3.08578087079232e+35',
385 ]
386
387 for s in test_strings:
388 negs = '-'+s
389 self.assertEqual(s, repr(float(s)))
390 self.assertEqual(negs, repr(float(negs)))
391
Christian Heimes99170a52007-12-19 02:07:34 +0000392# Beginning with Python 2.6 float has cross platform compatible
Georg Brandl2ee470f2008-07-16 12:55:28 +0000393# ways to create and represent inf and nan
Christian Heimes99170a52007-12-19 02:07:34 +0000394class InfNanTest(unittest.TestCase):
395 def test_inf_from_str(self):
396 self.assert_(isinf(float("inf")))
397 self.assert_(isinf(float("+inf")))
398 self.assert_(isinf(float("-inf")))
Georg Brandl2ee470f2008-07-16 12:55:28 +0000399 self.assert_(isinf(float("infinity")))
400 self.assert_(isinf(float("+infinity")))
401 self.assert_(isinf(float("-infinity")))
Christian Heimes99170a52007-12-19 02:07:34 +0000402
403 self.assertEqual(repr(float("inf")), "inf")
404 self.assertEqual(repr(float("+inf")), "inf")
405 self.assertEqual(repr(float("-inf")), "-inf")
Georg Brandl2ee470f2008-07-16 12:55:28 +0000406 self.assertEqual(repr(float("infinity")), "inf")
407 self.assertEqual(repr(float("+infinity")), "inf")
408 self.assertEqual(repr(float("-infinity")), "-inf")
Christian Heimes99170a52007-12-19 02:07:34 +0000409
410 self.assertEqual(repr(float("INF")), "inf")
411 self.assertEqual(repr(float("+Inf")), "inf")
412 self.assertEqual(repr(float("-iNF")), "-inf")
Georg Brandl2ee470f2008-07-16 12:55:28 +0000413 self.assertEqual(repr(float("Infinity")), "inf")
414 self.assertEqual(repr(float("+iNfInItY")), "inf")
415 self.assertEqual(repr(float("-INFINITY")), "-inf")
Christian Heimes99170a52007-12-19 02:07:34 +0000416
417 self.assertEqual(str(float("inf")), "inf")
418 self.assertEqual(str(float("+inf")), "inf")
419 self.assertEqual(str(float("-inf")), "-inf")
Georg Brandl2ee470f2008-07-16 12:55:28 +0000420 self.assertEqual(str(float("infinity")), "inf")
421 self.assertEqual(str(float("+infinity")), "inf")
422 self.assertEqual(str(float("-infinity")), "-inf")
Christian Heimes99170a52007-12-19 02:07:34 +0000423
424 self.assertRaises(ValueError, float, "info")
425 self.assertRaises(ValueError, float, "+info")
426 self.assertRaises(ValueError, float, "-info")
427 self.assertRaises(ValueError, float, "in")
428 self.assertRaises(ValueError, float, "+in")
429 self.assertRaises(ValueError, float, "-in")
Georg Brandl2ee470f2008-07-16 12:55:28 +0000430 self.assertRaises(ValueError, float, "infinit")
431 self.assertRaises(ValueError, float, "+Infin")
432 self.assertRaises(ValueError, float, "-INFI")
433 self.assertRaises(ValueError, float, "infinitys")
Christian Heimes99170a52007-12-19 02:07:34 +0000434
435 def test_inf_as_str(self):
436 self.assertEqual(repr(1e300 * 1e300), "inf")
437 self.assertEqual(repr(-1e300 * 1e300), "-inf")
438
439 self.assertEqual(str(1e300 * 1e300), "inf")
440 self.assertEqual(str(-1e300 * 1e300), "-inf")
441
442 def test_nan_from_str(self):
443 self.assert_(isnan(float("nan")))
444 self.assert_(isnan(float("+nan")))
445 self.assert_(isnan(float("-nan")))
446
447 self.assertEqual(repr(float("nan")), "nan")
448 self.assertEqual(repr(float("+nan")), "nan")
449 self.assertEqual(repr(float("-nan")), "nan")
450
451 self.assertEqual(repr(float("NAN")), "nan")
452 self.assertEqual(repr(float("+NAn")), "nan")
453 self.assertEqual(repr(float("-NaN")), "nan")
454
455 self.assertEqual(str(float("nan")), "nan")
456 self.assertEqual(str(float("+nan")), "nan")
457 self.assertEqual(str(float("-nan")), "nan")
458
459 self.assertRaises(ValueError, float, "nana")
460 self.assertRaises(ValueError, float, "+nana")
461 self.assertRaises(ValueError, float, "-nana")
462 self.assertRaises(ValueError, float, "na")
463 self.assertRaises(ValueError, float, "+na")
464 self.assertRaises(ValueError, float, "-na")
465
466 def test_nan_as_str(self):
467 self.assertEqual(repr(1e300 * 1e300 * 0), "nan")
468 self.assertEqual(repr(-1e300 * 1e300 * 0), "nan")
469
470 self.assertEqual(str(1e300 * 1e300 * 0), "nan")
471 self.assertEqual(str(-1e300 * 1e300 * 0), "nan")
Christian Heimes827b35c2007-12-10 22:19:17 +0000472
Christian Heimes53876d92008-04-19 00:31:39 +0000473 def notest_float_nan(self):
474 self.assert_(NAN.is_nan())
475 self.failIf(INF.is_nan())
476 self.failIf((0.).is_nan())
477
478 def notest_float_inf(self):
479 self.assert_(INF.is_inf())
480 self.failIf(NAN.is_inf())
481 self.failIf((0.).is_inf())
482
Mark Dickinson65fe25e2008-07-16 11:30:51 +0000483fromHex = float.fromhex
484toHex = float.hex
485class HexFloatTestCase(unittest.TestCase):
486 MAX = fromHex('0x.fffffffffffff8p+1024') # max normal
487 MIN = fromHex('0x1p-1022') # min normal
488 TINY = fromHex('0x0.0000000000001p-1022') # min subnormal
489 EPS = fromHex('0x0.0000000000001p0') # diff between 1.0 and next float up
490
491 def identical(self, x, y):
492 # check that floats x and y are identical, or that both
493 # are NaNs
494 if isnan(x) or isnan(y):
495 if isnan(x) == isnan(y):
496 return
497 elif x == y and (x != 0.0 or copysign(1.0, x) == copysign(1.0, y)):
498 return
499 self.fail('%r not identical to %r' % (x, y))
500
501 def test_ends(self):
Mark Dickinson38bbc482008-07-16 11:32:23 +0000502 self.identical(self.MIN, ldexp(1.0, -1022))
503 self.identical(self.TINY, ldexp(1.0, -1074))
504 self.identical(self.EPS, ldexp(1.0, -52))
505 self.identical(self.MAX, 2.*(ldexp(1.0, 1023) - ldexp(1.0, 970)))
Mark Dickinson65fe25e2008-07-16 11:30:51 +0000506
507 def test_invalid_inputs(self):
508 invalid_inputs = [
509 'infi', # misspelt infinities and nans
510 '-Infinit',
511 '++inf',
512 '-+Inf',
513 '--nan',
514 '+-NaN',
515 'snan',
516 'NaNs',
517 'nna',
518 '0xnan',
519 '',
520 ' ',
521 'x1.0p0',
522 '0xX1.0p0',
523 '+ 0x1.0p0', # internal whitespace
524 '- 0x1.0p0',
525 '0 x1.0p0',
526 '0x 1.0p0',
527 '0x1 2.0p0',
528 '+0x1 .0p0',
529 '0x1. 0p0',
530 '-0x1.0 1p0',
531 '-0x1.0 p0',
532 '+0x1.0p +0',
533 '0x1.0p -0',
534 '0x1.0p 0',
535 '+0x1.0p+ 0',
536 '-0x1.0p- 0',
537 '++0x1.0p-0', # double signs
538 '--0x1.0p0',
539 '+-0x1.0p+0',
540 '-+0x1.0p0',
541 '0x1.0p++0',
542 '+0x1.0p+-0',
543 '-0x1.0p-+0',
544 '0x1.0p--0',
545 '0x1.0.p0',
546 '0x.p0', # no hex digits before or after point
547 '0x1,p0', # wrong decimal point character
548 '0x1pa',
549 '0x1p\uff10', # fullwidth Unicode digits
550 '\uff10x1p0',
551 '0x\uff11p0',
552 '0x1.\uff10p0',
553 '0x1p0 \n 0x2p0',
554 '0x1p0\0 0x1p0', # embedded null byte is not end of string
555 ]
556 for x in invalid_inputs:
Mark Dickinson589b7952008-08-21 20:05:56 +0000557 try:
558 result = fromHex(x)
559 except ValueError:
560 pass
561 else:
562 self.fail('Expected float.fromhex(%r) to raise ValueError; '
563 'got %r instead' % (x, result))
Mark Dickinson65fe25e2008-07-16 11:30:51 +0000564
565
566 def test_from_hex(self):
567 MIN = self.MIN;
568 MAX = self.MAX;
569 TINY = self.TINY;
570 EPS = self.EPS;
571
572 # two spellings of infinity, with optional signs; case-insensitive
573 self.identical(fromHex('inf'), INF)
574 self.identical(fromHex('+Inf'), INF)
575 self.identical(fromHex('-INF'), -INF)
576 self.identical(fromHex('iNf'), INF)
577 self.identical(fromHex('Infinity'), INF)
578 self.identical(fromHex('+INFINITY'), INF)
579 self.identical(fromHex('-infinity'), -INF)
580 self.identical(fromHex('-iNFiNitY'), -INF)
581
582 # nans with optional sign; case insensitive
583 self.identical(fromHex('nan'), NAN)
584 self.identical(fromHex('+NaN'), NAN)
585 self.identical(fromHex('-NaN'), NAN)
586 self.identical(fromHex('-nAN'), NAN)
587
588 # variations in input format
589 self.identical(fromHex('1'), 1.0)
590 self.identical(fromHex('+1'), 1.0)
591 self.identical(fromHex('1.'), 1.0)
592 self.identical(fromHex('1.0'), 1.0)
593 self.identical(fromHex('1.0p0'), 1.0)
594 self.identical(fromHex('01'), 1.0)
595 self.identical(fromHex('01.'), 1.0)
596 self.identical(fromHex('0x1'), 1.0)
597 self.identical(fromHex('0x1.'), 1.0)
598 self.identical(fromHex('0x1.0'), 1.0)
599 self.identical(fromHex('+0x1.0'), 1.0)
600 self.identical(fromHex('0x1p0'), 1.0)
601 self.identical(fromHex('0X1p0'), 1.0)
602 self.identical(fromHex('0X1P0'), 1.0)
603 self.identical(fromHex('0x1P0'), 1.0)
604 self.identical(fromHex('0x1.p0'), 1.0)
605 self.identical(fromHex('0x1.0p0'), 1.0)
606 self.identical(fromHex('0x.1p4'), 1.0)
607 self.identical(fromHex('0x.1p04'), 1.0)
608 self.identical(fromHex('0x.1p004'), 1.0)
609 self.identical(fromHex('0x1p+0'), 1.0)
610 self.identical(fromHex('0x1P-0'), 1.0)
611 self.identical(fromHex('+0x1p0'), 1.0)
612 self.identical(fromHex('0x01p0'), 1.0)
613 self.identical(fromHex('0x1p00'), 1.0)
614 self.identical(fromHex(' 0x1p0 '), 1.0)
615 self.identical(fromHex('\n 0x1p0'), 1.0)
616 self.identical(fromHex('0x1p0 \t'), 1.0)
617 self.identical(fromHex('0xap0'), 10.0)
618 self.identical(fromHex('0xAp0'), 10.0)
619 self.identical(fromHex('0xaP0'), 10.0)
620 self.identical(fromHex('0xAP0'), 10.0)
621 self.identical(fromHex('0xbep0'), 190.0)
622 self.identical(fromHex('0xBep0'), 190.0)
623 self.identical(fromHex('0xbEp0'), 190.0)
624 self.identical(fromHex('0XBE0P-4'), 190.0)
625 self.identical(fromHex('0xBEp0'), 190.0)
626 self.identical(fromHex('0xB.Ep4'), 190.0)
627 self.identical(fromHex('0x.BEp8'), 190.0)
628 self.identical(fromHex('0x.0BEp12'), 190.0)
629
630 # moving the point around
631 pi = fromHex('0x1.921fb54442d18p1')
632 self.identical(fromHex('0x.006487ed5110b46p11'), pi)
633 self.identical(fromHex('0x.00c90fdaa22168cp10'), pi)
634 self.identical(fromHex('0x.01921fb54442d18p9'), pi)
635 self.identical(fromHex('0x.03243f6a8885a3p8'), pi)
636 self.identical(fromHex('0x.06487ed5110b46p7'), pi)
637 self.identical(fromHex('0x.0c90fdaa22168cp6'), pi)
638 self.identical(fromHex('0x.1921fb54442d18p5'), pi)
639 self.identical(fromHex('0x.3243f6a8885a3p4'), pi)
640 self.identical(fromHex('0x.6487ed5110b46p3'), pi)
641 self.identical(fromHex('0x.c90fdaa22168cp2'), pi)
642 self.identical(fromHex('0x1.921fb54442d18p1'), pi)
643 self.identical(fromHex('0x3.243f6a8885a3p0'), pi)
644 self.identical(fromHex('0x6.487ed5110b46p-1'), pi)
645 self.identical(fromHex('0xc.90fdaa22168cp-2'), pi)
646 self.identical(fromHex('0x19.21fb54442d18p-3'), pi)
647 self.identical(fromHex('0x32.43f6a8885a3p-4'), pi)
648 self.identical(fromHex('0x64.87ed5110b46p-5'), pi)
649 self.identical(fromHex('0xc9.0fdaa22168cp-6'), pi)
650 self.identical(fromHex('0x192.1fb54442d18p-7'), pi)
651 self.identical(fromHex('0x324.3f6a8885a3p-8'), pi)
652 self.identical(fromHex('0x648.7ed5110b46p-9'), pi)
653 self.identical(fromHex('0xc90.fdaa22168cp-10'), pi)
654 self.identical(fromHex('0x1921.fb54442d18p-11'), pi)
655 # ...
656 self.identical(fromHex('0x1921fb54442d1.8p-47'), pi)
657 self.identical(fromHex('0x3243f6a8885a3p-48'), pi)
658 self.identical(fromHex('0x6487ed5110b46p-49'), pi)
659 self.identical(fromHex('0xc90fdaa22168cp-50'), pi)
660 self.identical(fromHex('0x1921fb54442d18p-51'), pi)
661 self.identical(fromHex('0x3243f6a8885a30p-52'), pi)
662 self.identical(fromHex('0x6487ed5110b460p-53'), pi)
663 self.identical(fromHex('0xc90fdaa22168c0p-54'), pi)
664 self.identical(fromHex('0x1921fb54442d180p-55'), pi)
665
666
667 # results that should overflow...
668 self.assertRaises(OverflowError, fromHex, '-0x1p1024')
669 self.assertRaises(OverflowError, fromHex, '0x1p+1025')
670 self.assertRaises(OverflowError, fromHex, '+0X1p1030')
671 self.assertRaises(OverflowError, fromHex, '-0x1p+1100')
672 self.assertRaises(OverflowError, fromHex, '0X1p123456789123456789')
673 self.assertRaises(OverflowError, fromHex, '+0X.8p+1025')
674 self.assertRaises(OverflowError, fromHex, '+0x0.8p1025')
675 self.assertRaises(OverflowError, fromHex, '-0x0.4p1026')
676 self.assertRaises(OverflowError, fromHex, '0X2p+1023')
677 self.assertRaises(OverflowError, fromHex, '0x2.p1023')
678 self.assertRaises(OverflowError, fromHex, '-0x2.0p+1023')
679 self.assertRaises(OverflowError, fromHex, '+0X4p+1022')
680 self.assertRaises(OverflowError, fromHex, '0x1.ffffffffffffffp+1023')
681 self.assertRaises(OverflowError, fromHex, '-0X1.fffffffffffff9p1023')
682 self.assertRaises(OverflowError, fromHex, '0X1.fffffffffffff8p1023')
683 self.assertRaises(OverflowError, fromHex, '+0x3.fffffffffffffp1022')
684 self.assertRaises(OverflowError, fromHex, '0x3fffffffffffffp+970')
685 self.assertRaises(OverflowError, fromHex, '0x10000000000000000p960')
686 self.assertRaises(OverflowError, fromHex, '-0Xffffffffffffffffp960')
687
688 # ...and those that round to +-max float
689 self.identical(fromHex('+0x1.fffffffffffffp+1023'), MAX)
690 self.identical(fromHex('-0X1.fffffffffffff7p1023'), -MAX)
691 self.identical(fromHex('0X1.fffffffffffff7fffffffffffffp1023'), MAX)
692
693 # zeros
694 self.identical(fromHex('0x0p0'), 0.0)
695 self.identical(fromHex('0x0p1000'), 0.0)
696 self.identical(fromHex('-0x0p1023'), -0.0)
697 self.identical(fromHex('0X0p1024'), 0.0)
698 self.identical(fromHex('-0x0p1025'), -0.0)
699 self.identical(fromHex('0X0p2000'), 0.0)
700 self.identical(fromHex('0x0p123456789123456789'), 0.0)
701 self.identical(fromHex('-0X0p-0'), -0.0)
702 self.identical(fromHex('-0X0p-1000'), -0.0)
703 self.identical(fromHex('0x0p-1023'), 0.0)
704 self.identical(fromHex('-0X0p-1024'), -0.0)
705 self.identical(fromHex('-0x0p-1025'), -0.0)
706 self.identical(fromHex('-0x0p-1072'), -0.0)
707 self.identical(fromHex('0X0p-1073'), 0.0)
708 self.identical(fromHex('-0x0p-1074'), -0.0)
709 self.identical(fromHex('0x0p-1075'), 0.0)
710 self.identical(fromHex('0X0p-1076'), 0.0)
711 self.identical(fromHex('-0X0p-2000'), -0.0)
712 self.identical(fromHex('-0x0p-123456789123456789'), -0.0)
713
714 # values that should underflow to 0
715 self.identical(fromHex('0X1p-1075'), 0.0)
716 self.identical(fromHex('-0X1p-1075'), -0.0)
717 self.identical(fromHex('-0x1p-123456789123456789'), -0.0)
718 self.identical(fromHex('0x1.00000000000000001p-1075'), TINY)
719 self.identical(fromHex('-0x1.1p-1075'), -TINY)
720 self.identical(fromHex('0x1.fffffffffffffffffp-1075'), TINY)
721
722 # check round-half-even is working correctly near 0 ...
723 self.identical(fromHex('0x1p-1076'), 0.0)
724 self.identical(fromHex('0X2p-1076'), 0.0)
725 self.identical(fromHex('0X3p-1076'), TINY)
726 self.identical(fromHex('0x4p-1076'), TINY)
727 self.identical(fromHex('0X5p-1076'), TINY)
728 self.identical(fromHex('0X6p-1076'), 2*TINY)
729 self.identical(fromHex('0x7p-1076'), 2*TINY)
730 self.identical(fromHex('0X8p-1076'), 2*TINY)
731 self.identical(fromHex('0X9p-1076'), 2*TINY)
732 self.identical(fromHex('0xap-1076'), 2*TINY)
733 self.identical(fromHex('0Xbp-1076'), 3*TINY)
734 self.identical(fromHex('0xcp-1076'), 3*TINY)
735 self.identical(fromHex('0Xdp-1076'), 3*TINY)
736 self.identical(fromHex('0Xep-1076'), 4*TINY)
737 self.identical(fromHex('0xfp-1076'), 4*TINY)
738 self.identical(fromHex('0x10p-1076'), 4*TINY)
739 self.identical(fromHex('-0x1p-1076'), -0.0)
740 self.identical(fromHex('-0X2p-1076'), -0.0)
741 self.identical(fromHex('-0x3p-1076'), -TINY)
742 self.identical(fromHex('-0X4p-1076'), -TINY)
743 self.identical(fromHex('-0x5p-1076'), -TINY)
744 self.identical(fromHex('-0x6p-1076'), -2*TINY)
745 self.identical(fromHex('-0X7p-1076'), -2*TINY)
746 self.identical(fromHex('-0X8p-1076'), -2*TINY)
747 self.identical(fromHex('-0X9p-1076'), -2*TINY)
748 self.identical(fromHex('-0Xap-1076'), -2*TINY)
749 self.identical(fromHex('-0xbp-1076'), -3*TINY)
750 self.identical(fromHex('-0xcp-1076'), -3*TINY)
751 self.identical(fromHex('-0Xdp-1076'), -3*TINY)
752 self.identical(fromHex('-0xep-1076'), -4*TINY)
753 self.identical(fromHex('-0Xfp-1076'), -4*TINY)
754 self.identical(fromHex('-0X10p-1076'), -4*TINY)
755
756 # ... and near MIN ...
757 self.identical(fromHex('0x0.ffffffffffffd6p-1022'), MIN-3*TINY)
758 self.identical(fromHex('0x0.ffffffffffffd8p-1022'), MIN-2*TINY)
759 self.identical(fromHex('0x0.ffffffffffffdap-1022'), MIN-2*TINY)
760 self.identical(fromHex('0x0.ffffffffffffdcp-1022'), MIN-2*TINY)
761 self.identical(fromHex('0x0.ffffffffffffdep-1022'), MIN-2*TINY)
762 self.identical(fromHex('0x0.ffffffffffffe0p-1022'), MIN-2*TINY)
763 self.identical(fromHex('0x0.ffffffffffffe2p-1022'), MIN-2*TINY)
764 self.identical(fromHex('0x0.ffffffffffffe4p-1022'), MIN-2*TINY)
765 self.identical(fromHex('0x0.ffffffffffffe6p-1022'), MIN-2*TINY)
766 self.identical(fromHex('0x0.ffffffffffffe8p-1022'), MIN-2*TINY)
767 self.identical(fromHex('0x0.ffffffffffffeap-1022'), MIN-TINY)
768 self.identical(fromHex('0x0.ffffffffffffecp-1022'), MIN-TINY)
769 self.identical(fromHex('0x0.ffffffffffffeep-1022'), MIN-TINY)
770 self.identical(fromHex('0x0.fffffffffffff0p-1022'), MIN-TINY)
771 self.identical(fromHex('0x0.fffffffffffff2p-1022'), MIN-TINY)
772 self.identical(fromHex('0x0.fffffffffffff4p-1022'), MIN-TINY)
773 self.identical(fromHex('0x0.fffffffffffff6p-1022'), MIN-TINY)
774 self.identical(fromHex('0x0.fffffffffffff8p-1022'), MIN)
775 self.identical(fromHex('0x0.fffffffffffffap-1022'), MIN)
776 self.identical(fromHex('0x0.fffffffffffffcp-1022'), MIN)
777 self.identical(fromHex('0x0.fffffffffffffep-1022'), MIN)
778 self.identical(fromHex('0x1.00000000000000p-1022'), MIN)
779 self.identical(fromHex('0x1.00000000000002p-1022'), MIN)
780 self.identical(fromHex('0x1.00000000000004p-1022'), MIN)
781 self.identical(fromHex('0x1.00000000000006p-1022'), MIN)
782 self.identical(fromHex('0x1.00000000000008p-1022'), MIN)
783 self.identical(fromHex('0x1.0000000000000ap-1022'), MIN+TINY)
784 self.identical(fromHex('0x1.0000000000000cp-1022'), MIN+TINY)
785 self.identical(fromHex('0x1.0000000000000ep-1022'), MIN+TINY)
786 self.identical(fromHex('0x1.00000000000010p-1022'), MIN+TINY)
787 self.identical(fromHex('0x1.00000000000012p-1022'), MIN+TINY)
788 self.identical(fromHex('0x1.00000000000014p-1022'), MIN+TINY)
789 self.identical(fromHex('0x1.00000000000016p-1022'), MIN+TINY)
790 self.identical(fromHex('0x1.00000000000018p-1022'), MIN+2*TINY)
791
792 # ... and near 1.0.
793 self.identical(fromHex('0x0.fffffffffffff0p0'), 1.0-EPS)
794 self.identical(fromHex('0x0.fffffffffffff1p0'), 1.0-EPS)
795 self.identical(fromHex('0X0.fffffffffffff2p0'), 1.0-EPS)
796 self.identical(fromHex('0x0.fffffffffffff3p0'), 1.0-EPS)
797 self.identical(fromHex('0X0.fffffffffffff4p0'), 1.0-EPS)
798 self.identical(fromHex('0X0.fffffffffffff5p0'), 1.0-EPS/2)
799 self.identical(fromHex('0X0.fffffffffffff6p0'), 1.0-EPS/2)
800 self.identical(fromHex('0x0.fffffffffffff7p0'), 1.0-EPS/2)
801 self.identical(fromHex('0x0.fffffffffffff8p0'), 1.0-EPS/2)
802 self.identical(fromHex('0X0.fffffffffffff9p0'), 1.0-EPS/2)
803 self.identical(fromHex('0X0.fffffffffffffap0'), 1.0-EPS/2)
804 self.identical(fromHex('0x0.fffffffffffffbp0'), 1.0-EPS/2)
805 self.identical(fromHex('0X0.fffffffffffffcp0'), 1.0)
806 self.identical(fromHex('0x0.fffffffffffffdp0'), 1.0)
807 self.identical(fromHex('0X0.fffffffffffffep0'), 1.0)
808 self.identical(fromHex('0x0.ffffffffffffffp0'), 1.0)
809 self.identical(fromHex('0X1.00000000000000p0'), 1.0)
810 self.identical(fromHex('0X1.00000000000001p0'), 1.0)
811 self.identical(fromHex('0x1.00000000000002p0'), 1.0)
812 self.identical(fromHex('0X1.00000000000003p0'), 1.0)
813 self.identical(fromHex('0x1.00000000000004p0'), 1.0)
814 self.identical(fromHex('0X1.00000000000005p0'), 1.0)
815 self.identical(fromHex('0X1.00000000000006p0'), 1.0)
816 self.identical(fromHex('0X1.00000000000007p0'), 1.0)
817 self.identical(fromHex('0x1.00000000000007ffffffffffffffffffffp0'),
818 1.0)
819 self.identical(fromHex('0x1.00000000000008p0'), 1.0)
820 self.identical(fromHex('0x1.00000000000008000000000000000001p0'),
821 1+EPS)
822 self.identical(fromHex('0X1.00000000000009p0'), 1.0+EPS)
823 self.identical(fromHex('0x1.0000000000000ap0'), 1.0+EPS)
824 self.identical(fromHex('0x1.0000000000000bp0'), 1.0+EPS)
825 self.identical(fromHex('0X1.0000000000000cp0'), 1.0+EPS)
826 self.identical(fromHex('0x1.0000000000000dp0'), 1.0+EPS)
827 self.identical(fromHex('0x1.0000000000000ep0'), 1.0+EPS)
828 self.identical(fromHex('0X1.0000000000000fp0'), 1.0+EPS)
829 self.identical(fromHex('0x1.00000000000010p0'), 1.0+EPS)
830 self.identical(fromHex('0X1.00000000000011p0'), 1.0+EPS)
831 self.identical(fromHex('0x1.00000000000012p0'), 1.0+EPS)
832 self.identical(fromHex('0X1.00000000000013p0'), 1.0+EPS)
833 self.identical(fromHex('0X1.00000000000014p0'), 1.0+EPS)
834 self.identical(fromHex('0x1.00000000000015p0'), 1.0+EPS)
835 self.identical(fromHex('0x1.00000000000016p0'), 1.0+EPS)
836 self.identical(fromHex('0X1.00000000000017p0'), 1.0+EPS)
837 self.identical(fromHex('0x1.00000000000017ffffffffffffffffffffp0'),
838 1.0+EPS)
839 self.identical(fromHex('0x1.00000000000018p0'), 1.0+2*EPS)
840 self.identical(fromHex('0X1.00000000000018000000000000000001p0'),
841 1.0+2*EPS)
842 self.identical(fromHex('0x1.00000000000019p0'), 1.0+2*EPS)
843 self.identical(fromHex('0X1.0000000000001ap0'), 1.0+2*EPS)
844 self.identical(fromHex('0X1.0000000000001bp0'), 1.0+2*EPS)
845 self.identical(fromHex('0x1.0000000000001cp0'), 1.0+2*EPS)
846 self.identical(fromHex('0x1.0000000000001dp0'), 1.0+2*EPS)
847 self.identical(fromHex('0x1.0000000000001ep0'), 1.0+2*EPS)
848 self.identical(fromHex('0X1.0000000000001fp0'), 1.0+2*EPS)
849 self.identical(fromHex('0x1.00000000000020p0'), 1.0+2*EPS)
850
851 def test_roundtrip(self):
852 def roundtrip(x):
853 return fromHex(toHex(x))
854
855 for x in [NAN, INF, self.MAX, self.MIN, self.MIN-self.TINY, self.TINY, 0.0]:
856 self.identical(x, roundtrip(x))
857 self.identical(-x, roundtrip(-x))
858
859 # fromHex(toHex(x)) should exactly recover x, for any non-NaN float x.
860 import random
861 for i in range(10000):
862 e = random.randrange(-1200, 1200)
863 m = random.random()
864 s = random.choice([1.0, -1.0])
865 try:
866 x = s*ldexp(m, e)
867 except OverflowError:
868 pass
869 else:
870 self.identical(x, fromHex(toHex(x)))
871
Christian Heimes53876d92008-04-19 00:31:39 +0000872
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000873def test_main():
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000874 support.run_unittest(
Amaury Forgeot d'Arc7e958d12008-09-06 21:03:22 +0000875 GeneralFloatCases,
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000876 FormatFunctionsTestCase,
877 UnknownFormatTestCase,
Eric Smith8c663262007-08-25 02:26:07 +0000878 IEEEFormatTestCase,
Christian Heimes827b35c2007-12-10 22:19:17 +0000879 FormatTestCase,
Christian Heimes99170a52007-12-19 02:07:34 +0000880 ReprTestCase,
881 InfNanTest,
Mark Dickinson65fe25e2008-07-16 11:30:51 +0000882 HexFloatTestCase,
Christian Heimesb76922a2007-12-11 01:06:40 +0000883 )
Michael W. Hudsonba283e22005-05-27 15:23:20 +0000884
885if __name__ == '__main__':
886 test_main()