diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-02-06 22:10:50 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-02-06 22:10:50 +0000 |
commit | 2fc9263df56d28a6c1def6c8a0517bbddfa899af (patch) | |
tree | 3a4f03d86c54781d8db9d9f03eb0d9ba20e44e0d /Lib/test/test_decimal.py | |
parent | 55b8c3e26fe608a1caf65cb35e41cdcbd8353426 (diff) | |
download | cpython-git-2fc9263df56d28a6c1def6c8a0517bbddfa899af.tar.gz |
Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN
raise InvalidOperation (and return False if InvalidOperation is trapped).
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 0c8852c400..3b15df76c6 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -838,6 +838,19 @@ class DecimalArithmeticOperatorsTest(unittest.TestCase): self.assertEqual(-Decimal(45), Decimal(-45)) # - self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs + def test_nan_comparisons(self): + n = Decimal('NaN') + s = Decimal('sNaN') + i = Decimal('Inf') + f = Decimal('2') + for x, y in [(n, n), (n, i), (i, n), (n, f), (f, n), + (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s)]: + self.assert_(x != y) + self.assert_(not (x == y)) + self.assert_(not (x < y)) + self.assert_(not (x <= y)) + self.assert_(not (x > y)) + self.assert_(not (x >= y)) # The following are two functions used to test threading in the next class @@ -1147,7 +1160,12 @@ class DecimalUsabilityTest(unittest.TestCase): checkSameDec("__add__", True) checkSameDec("__div__", True) checkSameDec("__divmod__", True) - checkSameDec("__cmp__", True) + checkSameDec("__eq__", True) + checkSameDec("__ne__", True) + checkSameDec("__le__", True) + checkSameDec("__lt__", True) + checkSameDec("__ge__", True) + checkSameDec("__gt__", True) checkSameDec("__float__") checkSameDec("__floordiv__", True) checkSameDec("__hash__") |