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

Method test_ieee_context

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

IEEEContextFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected