mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
tests: Add missing tests for builtins, and many other things.
This commit is contained in:
@@ -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([])
|
||||
|
||||
Reference in New Issue
Block a user