(self)
| 135 | self.check_equal_hash(D('12300.000'), D(12300)) |
| 136 | |
| 137 | def test_fractions(self): |
| 138 | # check special case for fractions where either the numerator |
| 139 | # or the denominator is a multiple of _PyHASH_MODULUS |
| 140 | self.assertEqual(hash(F(1, _PyHASH_MODULUS)), _PyHASH_INF) |
| 141 | self.assertEqual(hash(F(-1, 3*_PyHASH_MODULUS)), -_PyHASH_INF) |
| 142 | self.assertEqual(hash(F(7*_PyHASH_MODULUS, 1)), 0) |
| 143 | self.assertEqual(hash(F(-_PyHASH_MODULUS, 1)), 0) |
| 144 | |
| 145 | # The numbers ABC doesn't enforce that the "true" division |
| 146 | # of integers produces a float. This tests that the |
| 147 | # Rational.__float__() method has required type conversions. |
| 148 | x = F._from_coprime_ints(DummyIntegral(1), DummyIntegral(2)) |
| 149 | self.assertRaises(TypeError, lambda: x.numerator/x.denominator) |
| 150 | self.assertEqual(float(x), 0.5) |
| 151 | |
| 152 | def test_hash_normalization(self): |
| 153 | # Test for a bug encountered while changing long_hash. |
nothing calls this directly
no test coverage detected