| 2051 | # tested. |
| 2052 | @unittest.skipUnless(verbose, 'requires verbose mode') |
| 2053 | def test_exceptions(self): |
| 2054 | try: |
| 2055 | x = math.exp(-1000000000) |
| 2056 | except: |
| 2057 | # mathmodule.c is failing to weed out underflows from libm, or |
| 2058 | # we've got an fp format with huge dynamic range |
| 2059 | self.fail("underflowing exp() should not have raised " |
| 2060 | "an exception") |
| 2061 | if x != 0: |
| 2062 | self.fail("underflowing exp() should have returned 0") |
| 2063 | |
| 2064 | # If this fails, probably using a strict IEEE-754 conforming libm, and x |
| 2065 | # is +Inf afterwards. But Python wants overflows detected by default. |
| 2066 | try: |
| 2067 | x = math.exp(1000000000) |
| 2068 | except OverflowError: |
| 2069 | pass |
| 2070 | else: |
| 2071 | self.fail("overflowing exp() didn't trigger OverflowError") |
| 2072 | |
| 2073 | # If this fails, it could be a puzzle. One odd possibility is that |
| 2074 | # mathmodule.c's macros are getting confused while comparing |
| 2075 | # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE |
| 2076 | # as a result (and so raising OverflowError instead). |
| 2077 | try: |
| 2078 | x = math.sqrt(-1.0) |
| 2079 | except ValueError: |
| 2080 | pass |
| 2081 | else: |
| 2082 | self.fail("sqrt(-1) didn't raise ValueError") |
| 2083 | |
| 2084 | @requires_IEEE_754 |
| 2085 | def test_testfile(self): |