diff options
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index dbd58e8..efb41fd 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -276,6 +276,7 @@ class IBMTestCases(unittest.TestCase): 'is_snan', 'is_subnormal', 'is_zero', + 'is_integer', 'same_quantum') def read_unlimited(self, v, context): @@ -2726,6 +2727,7 @@ class PythonAPItests(unittest.TestCase): self.assertRaises(TypeError, D(1).is_snan, context=xc) self.assertRaises(TypeError, D(1).is_signed, context=xc) self.assertRaises(TypeError, D(1).is_zero, context=xc) + self.assertRaises(TypeError, D(1).is_integer, context=xc) self.assertFalse(D("0.01").is_normal(context=xc)) self.assertTrue(D("0.01").is_subnormal(context=xc)) @@ -3197,6 +3199,15 @@ class ContextAPItests(unittest.TestCase): self.assertEqual(c.is_zero(10), d) self.assertRaises(TypeError, c.is_zero, '10') + def test_is_integer(self): + Decimal = self.decimal.Decimal + Context = self.decimal.Context + + c = Context() + b = c.is_integer(Decimal(10)) + self.assertEqual(c.is_integer(10), b) + self.assertRaises(TypeError, c.is_integer, '10') + def test_ln(self): Decimal = self.decimal.Decimal Context = self.decimal.Context @@ -4360,6 +4371,19 @@ class Coverage(unittest.TestCase): self.assertTrue(Decimal("-1").is_signed()) self.assertTrue(Decimal("0").is_zero()) self.assertTrue(Decimal("0").is_zero()) + self.assertTrue(Decimal("-1").is_integer()) + self.assertTrue(Decimal("0").is_integer()) + self.assertTrue(Decimal("1").is_integer()) + self.assertTrue(Decimal("42").is_integer()) + self.assertTrue(Decimal("1e2").is_integer()) + self.assertFalse(Decimal("1.5").is_integer()) + self.assertFalse(Decimal("1e-2").is_integer()) + self.assertFalse(Decimal("NaN").is_integer()) + self.assertFalse(Decimal("-NaN").is_integer()) + self.assertFalse(Decimal("sNaN").is_integer()) + self.assertFalse(Decimal("-sNaN").is_integer()) + self.assertFalse(Decimal("Inf").is_integer()) + self.assertFalse(Decimal("-Inf").is_integer()) # Copy with localcontext() as c: |