mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 21:20:13 +01:00
tests/basics: Add tests for equality between bool and int/float/complex.
False/True should be implicitly converted to 0/1 when compared with numeric types.
This commit is contained in:
@@ -36,6 +36,8 @@ ans = 1j ** 2.5j; print("%.5g %.5g" % (ans.real, ans.imag))
|
||||
# comparison
|
||||
print(1j == 1)
|
||||
print(1j == 1j)
|
||||
print(0 + 0j == False, 1 + 0j == True)
|
||||
print(False == 0 + 0j, True == 1 + 0j)
|
||||
|
||||
# comparison of nan is special
|
||||
nan = float('nan') * 1j
|
||||
|
||||
@@ -64,6 +64,8 @@ print(1.2 <= 3.4)
|
||||
print(1.2 <= -3.4)
|
||||
print(1.2 >= 3.4)
|
||||
print(1.2 >= -3.4)
|
||||
print(0.0 == False, 1.0 == True)
|
||||
print(False == 0.0, True == 1.0)
|
||||
|
||||
# comparison of nan is special
|
||||
nan = float('nan')
|
||||
|
||||
Reference in New Issue
Block a user