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

Method test_none_args

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

Source from the content-addressed store, hash-verified

2314 str(c.sqrt(Decimal(0))))
2315
2316 def test_none_args(self):
2317 Decimal = self.decimal.Decimal
2318 Context = self.decimal.Context
2319 localcontext = self.decimal.localcontext
2320 InvalidOperation = self.decimal.InvalidOperation
2321 DivisionByZero = self.decimal.DivisionByZero
2322 Overflow = self.decimal.Overflow
2323 Underflow = self.decimal.Underflow
2324 Subnormal = self.decimal.Subnormal
2325 Inexact = self.decimal.Inexact
2326 Rounded = self.decimal.Rounded
2327 Clamped = self.decimal.Clamped
2328
2329 with localcontext(Context()) as c:
2330 c.prec = 7
2331 c.Emax = 999
2332 c.Emin = -999
2333
2334 x = Decimal("111")
2335 y = Decimal("1e9999")
2336 z = Decimal("1e-9999")
2337
2338 ##### Unary functions
2339 c.clear_flags()
2340 self.assertEqual(str(x.exp(context=None)), '1.609487E+48')
2341 self.assertTrue(c.flags[Inexact])
2342 self.assertTrue(c.flags[Rounded])
2343 c.clear_flags()
2344 self.assertRaises(Overflow, y.exp, context=None)
2345 self.assertTrue(c.flags[Overflow])
2346
2347 self.assertIs(z.is_normal(context=None), False)
2348 self.assertIs(z.is_subnormal(context=None), True)
2349
2350 c.clear_flags()
2351 self.assertEqual(str(x.ln(context=None)), '4.709530')
2352 self.assertTrue(c.flags[Inexact])
2353 self.assertTrue(c.flags[Rounded])
2354 c.clear_flags()
2355 self.assertRaises(InvalidOperation, Decimal(-1).ln, context=None)
2356 self.assertTrue(c.flags[InvalidOperation])
2357
2358 c.clear_flags()
2359 self.assertEqual(str(x.log10(context=None)), '2.045323')
2360 self.assertTrue(c.flags[Inexact])
2361 self.assertTrue(c.flags[Rounded])
2362 c.clear_flags()
2363 self.assertRaises(InvalidOperation, Decimal(-1).log10, context=None)
2364 self.assertTrue(c.flags[InvalidOperation])
2365
2366 c.clear_flags()
2367 self.assertEqual(str(x.logb(context=None)), '2')
2368 self.assertRaises(DivisionByZero, Decimal(0).logb, context=None)
2369 self.assertTrue(c.flags[DivisionByZero])
2370
2371 c.clear_flags()
2372 self.assertEqual(str(x.logical_invert(context=None)), '1111000')
2373 self.assertRaises(InvalidOperation, y.logical_invert, context=None)

Callers

nothing calls this directly

Calls 15

expMethod · 0.95
is_normalMethod · 0.95
is_subnormalMethod · 0.95
lnMethod · 0.95
log10Method · 0.95
logbMethod · 0.95
logical_invertMethod · 0.95
next_minusMethod · 0.95
next_plusMethod · 0.95
normalizeMethod · 0.95
number_classMethod · 0.95
sqrtMethod · 0.95

Tested by

no test coverage detected