diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-02 23:04:09 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-02 23:04:09 +0000 |
commit | 6fd4b36bc5dfbb6c6a3f85e14269589e6613d26d (patch) | |
tree | b069fd33c8d9b3a7532736d6d08da1e28427a002 /tests/float/float2int.py | |
parent | 6e0b6d02dbe238e6e3d675b51e44b2ac798ddd20 (diff) | |
download | micropython-6fd4b36bc5dfbb6c6a3f85e14269589e6613d26d.tar.gz micropython-6fd4b36bc5dfbb6c6a3f85e14269589e6613d26d.zip |
py: Raise exception if trying to convert inf/nan to int.
Diffstat (limited to 'tests/float/float2int.py')
-rw-r--r-- | tests/float/float2int.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/float/float2int.py b/tests/float/float2int.py index b948755de5..42210b4413 100644 --- a/tests/float/float2int.py +++ b/tests/float/float2int.py @@ -22,3 +22,15 @@ for i in range(0,23): print('fail: 10**%u was %u digits long' % (i, digcnt)); testpass = False print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) + +# test inf conversion +try: + int(float('inf')) +except OverflowError: + print("OverflowError") + +# test nan conversion +try: + int(float('nan')) +except ValueError: + print("ValueError") |