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

Method test_trunc

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

Source from the content-addressed store, hash-verified

2697 self.assertIs(int(Decimal(x)), x)
2698
2699 def test_trunc(self):
2700 Decimal = self.decimal.Decimal
2701
2702 for x in range(-250, 250):
2703 s = '%0.2f' % (x / 100.0)
2704 # should work the same as for floats
2705 self.assertEqual(int(Decimal(s)), int(float(s)))
2706 # should work the same as to_integral in the ROUND_DOWN mode
2707 d = Decimal(s)
2708 r = d.to_integral(ROUND_DOWN)
2709 self.assertEqual(Decimal(math.trunc(d)), r)
2710
2711 def test_from_float(self):
2712

Callers

nothing calls this directly

Calls 3

DecimalClass · 0.85
truncMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected