summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/float1.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-31 02:20:00 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-31 02:23:57 +0300
commit6ded55a61f6bbf007d518fc4531287de08fe51c4 (patch)
treef78ee04bd9636bea80d6b63d86f8044c76fdb17a /tests/basics/float1.py
parent96ed213320cb627c1df7ea8550b86b0bba5cb559 (diff)
downloadmicropython-6ded55a61f6bbf007d518fc4531287de08fe51c4.tar.gz
micropython-6ded55a61f6bbf007d518fc4531287de08fe51c4.zip
py: Properly implement divide-by-zero handling.
"1/0" is sacred idiom, the shortest way to break program execution (sys.exit() is too long).
Diffstat (limited to 'tests/basics/float1.py')
-rw-r--r--tests/basics/float1.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/basics/float1.py b/tests/basics/float1.py
index 200d955856..bf1305c3d5 100644
--- a/tests/basics/float1.py
+++ b/tests/basics/float1.py
@@ -1,3 +1,16 @@
# basic float
x = 1 / 2
print(x)
+
+print(1.0 // 2)
+print(2.0 // 2)
+
+try:
+ 1.0 / 0
+except ZeroDivisionError:
+ print("ZeroDivisionError")
+
+try:
+ 1.0 // 0
+except ZeroDivisionError:
+ print("ZeroDivisionError")