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

Method test_ieee_context

Lib/test/test_decimal.py:4424–4454  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4422class IEEEContexts:
4423
4424 def test_ieee_context(self):
4425 # issue 8786: Add support for IEEE 754 contexts to decimal module.
4426 IEEEContext = self.decimal.IEEEContext
4427
4428 def assert_rest(self, context):
4429 self.assertEqual(context.clamp, 1)
4430 assert_signals(self, context, 'traps', [])
4431 assert_signals(self, context, 'flags', [])
4432
4433 c = IEEEContext(32)
4434 self.assertEqual(c.prec, 7)
4435 self.assertEqual(c.Emax, 96)
4436 self.assertEqual(c.Emin, -95)
4437 assert_rest(self, c)
4438
4439 c = IEEEContext(64)
4440 self.assertEqual(c.prec, 16)
4441 self.assertEqual(c.Emax, 384)
4442 self.assertEqual(c.Emin, -383)
4443 assert_rest(self, c)
4444
4445 c = IEEEContext(128)
4446 self.assertEqual(c.prec, 34)
4447 self.assertEqual(c.Emax, 6144)
4448 self.assertEqual(c.Emin, -6143)
4449 assert_rest(self, c)
4450
4451 # Invalid values
4452 self.assertRaises(ValueError, IEEEContext, -1)
4453 self.assertRaises(ValueError, IEEEContext, 123)
4454 self.assertRaises(ValueError, IEEEContext, 1024)
4455
4456 def test_constants(self):
4457 # IEEEContext

Callers

nothing calls this directly

Calls 3

IEEEContextFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected