Commit 4307c072 authored by Boxiang Sun's avatar Boxiang Sun

add tests for new added complex attributes

parent fd811164
......@@ -22,3 +22,36 @@ try:
complex(1, 1.0).real = 1
except TypeError, e:
print e
types = [int, float, long]
for _type in types:
try:
_type(1j)
except TypeError as e:
print(e.message)
data = ["-1j", "0j", "1j",
"5+5j", "5-5j",
"5", "5L", "5.5",
"\"5\"", "None",
]
operations = ["__mod__", "__rmod__",
"__divmod__", "__rdivmod__",
"__truediv__", "__rtruediv__",
"__floordiv__", "__rfloordiv__",
]
for x in data:
for y in data:
for operation in operations:
try:
print(x)
print(y)
print(operation)
print(eval("complex.{op}({arg1}, {arg2})".format(op=operation,
arg1=x,
arg2=y)))
print("========")
except Exception as e:
print(e.message)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment