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

Method test_trunc

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

DecimalClass · 0.85
truncMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected