From 6ded55a61f6bbf007d518fc4531287de08fe51c4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 31 Mar 2014 02:20:00 +0300 Subject: py: Properly implement divide-by-zero handling. "1/0" is sacred idiom, the shortest way to break program execution (sys.exit() is too long). --- tests/basics/float1.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/basics/float1.py') diff --git a/tests/basics/float1.py b/tests/basics/float1.py index 200d95585..bf1305c3d 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") -- cgit v1.2.3