summaryrefslogtreecommitdiffstatshomepage
path: root/tests/float/float2int.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-02 23:04:09 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-02 23:04:09 +0000
commit6fd4b36bc5dfbb6c6a3f85e14269589e6613d26d (patch)
treeb069fd33c8d9b3a7532736d6d08da1e28427a002 /tests/float/float2int.py
parent6e0b6d02dbe238e6e3d675b51e44b2ac798ddd20 (diff)
downloadmicropython-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.py12
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")