2015-03-25 23:10:09 +00:00
|
|
|
# tests for bool objects
|
|
|
|
|
|
|
|
# basic logic
|
|
|
|
print(not False)
|
|
|
|
print(not True)
|
|
|
|
print(False and True)
|
|
|
|
print(False or True)
|
|
|
|
|
|
|
|
# unary operators
|
|
|
|
print(+True)
|
|
|
|
print(-True)
|
2015-08-25 17:18:57 +00:00
|
|
|
|
2020-02-10 11:22:12 +00:00
|
|
|
# comparison with itself
|
|
|
|
print(False == False)
|
|
|
|
print(False == True)
|
|
|
|
print(True == False)
|
|
|
|
print(True == True)
|
|
|
|
print(False != False)
|
|
|
|
print(False != True)
|
|
|
|
print(True != False)
|
|
|
|
print(True != True)
|
|
|
|
|
|
|
|
# comparison with integers
|
|
|
|
print(False == 0)
|
|
|
|
print(0 == False)
|
|
|
|
print(True == 1)
|
|
|
|
print(1 == True)
|
|
|
|
print(True == 2)
|
|
|
|
print(2 == True)
|
|
|
|
print(False != 0)
|
|
|
|
print(0 != False)
|
|
|
|
print(True != 1)
|
|
|
|
print(1 != True)
|
|
|
|
print(True != 2)
|
|
|
|
print(2 != True)
|
|
|
|
|
2015-08-25 17:18:57 +00:00
|
|
|
# unsupported unary op
|
|
|
|
try:
|
|
|
|
len(False)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|