2015-03-25 19:10:09 -04:00
|
|
|
# test errors from bad operations (unary, binary, etc)
|
|
|
|
|
|
|
|
# unsupported unary operators
|
2018-02-14 00:50:20 -05:00
|
|
|
try:
|
|
|
|
~None
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
~''
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
~[]
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 19:10:09 -04:00
|
|
|
|
|
|
|
# unsupported binary operators
|
2018-02-14 00:50:20 -05:00
|
|
|
try:
|
|
|
|
False in True
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
1 * {}
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
1 in 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 19:10:09 -04:00
|
|
|
|
|
|
|
# unsupported subscription
|
2018-02-14 00:50:20 -05:00
|
|
|
try:
|
|
|
|
1[0] = 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
'a'[0] = 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
del 1[0]
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 19:10:09 -04:00
|
|
|
|
|
|
|
# not an iterator
|
2018-02-14 00:50:20 -05:00
|
|
|
try:
|
|
|
|
next(1)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 19:10:09 -04:00
|
|
|
|
|
|
|
# must be an exception type
|
2018-02-14 00:50:20 -05:00
|
|
|
try:
|
|
|
|
raise 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 19:10:09 -04:00
|
|
|
|
|
|
|
# no such name in import
|
2018-02-14 00:50:20 -05:00
|
|
|
try:
|
|
|
|
from sys import youcannotimportmebecauseidontexist
|
|
|
|
except ImportError:
|
|
|
|
print('ImportError')
|