diff options
author | Damien George <damien.p.george@gmail.com> | 2015-04-04 22:05:30 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-04-04 22:05:30 +0100 |
commit | 9dd36404646f857c4f250537bac0d9a8ad041d25 (patch) | |
tree | c6509bcd3c7d5c2e67332110c582df2b5a5c669f /tests/float/float1.py | |
parent | 7e758b1cf878312cab5d9d2825b36e7235ea10a3 (diff) | |
download | micropython-9dd36404646f857c4f250537bac0d9a8ad041d25.tar.gz micropython-9dd36404646f857c4f250537bac0d9a8ad041d25.zip |
tests: Add missing tests for builtins, and many other things.
Diffstat (limited to 'tests/float/float1.py')
-rw-r--r-- | tests/float/float1.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/float/float1.py b/tests/float/float1.py index 9e4bb85cd1..2539d89dc3 100644 --- a/tests/float/float1.py +++ b/tests/float/float1.py @@ -1,4 +1,15 @@ -# basic float +# test basic float capabilities + +# float construction +print(float(1.2)) + +# unary operators +print(bool(0.0)) +print(bool(1.2)) +print(+(1.2)) +print(-(1.2)) + +# division of integers x = 1 / 2 print(x) @@ -7,9 +18,16 @@ a = 1 a /= 2 print(a) +# floor division print(1.0 // 2) print(2.0 // 2) +# comparison +print(1.2 <= 3.4) +print(1.2 <= -3.4) +print(1.2 >= 3.4) +print(1.2 >= -3.4) + try: 1.0 / 0 except ZeroDivisionError: @@ -20,6 +38,23 @@ try: except ZeroDivisionError: print("ZeroDivisionError") +try: + 1.2 % 0 +except ZeroDivisionError: + print("ZeroDivisionError") + +# unsupported unary ops + +try: + ~1.2 +except TypeError: + print("TypeError") + +try: + 1.2 in 3.4 +except TypeError: + print("TypeError") + # can't convert list to float try: float([]) |