diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-10-16 17:33:50 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-10-16 17:33:50 (GMT) |
commit | a8268e945778dac4e92421545573424eb495f918 (patch) | |
tree | 03584ae49808edfd865121c4990bf9d461543deb /Lib/dos-8x3/test_mat.py | |
parent | 1a2ca86a4f2356bb4d545f60f2da888cd13123a4 (diff) | |
download | cpython-a8268e945778dac4e92421545573424eb495f918.zip cpython-a8268e945778dac4e92421545573424eb495f918.tar.gz cpython-a8268e945778dac4e92421545573424eb495f918.tar.bz2 |
the usual
Diffstat (limited to 'Lib/dos-8x3/test_mat.py')
-rw-r--r-- | Lib/dos-8x3/test_mat.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/dos-8x3/test_mat.py b/Lib/dos-8x3/test_mat.py index 6d6bc44..1452035 100644 --- a/Lib/dos-8x3/test_mat.py +++ b/Lib/dos-8x3/test_mat.py @@ -152,3 +152,34 @@ testit('tan(-pi/4)', math.tan(-math.pi/4), -1) print 'tanh' testit('tanh(0)', math.tanh(0), 0) testit('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0) + +print 'exceptions' # oooooh, *this* is a x-platform gamble! good luck + +try: + x = math.exp(-1000000000) +except: + # mathmodule.c is failing to weed out underflows from libm, or + # we've got an fp format with huge dynamic range + raise TestFailed("underflowing exp() should not have rasied an exception") +if x != 0: + raise TestFailed("underflowing exp() should have returned 0") + +# If this fails, probably using a strict IEEE-754 conforming libm, and x +# is +Inf afterwards. But Python wants overflows detected by default. +try: + x = math.exp(1000000000) +except OverflowError: + pass +else: + raise TestFailed("overflowing exp() didn't trigger OverflowError") + +# If this fails, it could be a puzzle. One odd possibility is that +# mathmodule.c's CHECK() macro is getting confused while comparing +# Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE +# as a result (and so raising OverflowError instead). +try: + x = math.sqrt(-1.0) +except ValueError: + pass +else: + raise TestFailed("sqrt(-1) didn't raise ValueError") |