Commit 065ac619 authored by Boxiang Sun's avatar Boxiang Sun

add missing int attributes compared with CPython

parent bd361100
This diff is collapsed.
...@@ -178,3 +178,42 @@ if sys.version_info >= (2, 7, 6): ...@@ -178,3 +178,42 @@ if sys.version_info >= (2, 7, 6):
print(e.message) print(e.message)
else: else:
print("int() missing string argument") print("int() missing string argument")
unary_test_data = [-42, -0, 0, 42]
for i in unary_test_data:
print(int.__abs__(i))
print(int.__long__(i))
data = ["-1", "0", "1",
"5", "-5",
"5.0", "5L", "0L", "5+5j", "0.0",
"\"5\"", "None",
]
operations = ["__radd__",
"__rand__",
"__ror__",
"__rxor__",
"__rsub__",
"__rmul__",
"__rdiv__",
"__rfloordiv__",
"__rpow__",
"__rmod__",
"__rdivmod__",
"__rtruediv__",
"__rrshift__",
"__rlshift__",
"__coerce__",
]
for x in data:
for y in data:
for operation in operations:
try:
print(eval("int.{op}({arg1}, {arg2})".format(op=operation,
arg1=x,
arg2=y)))
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