mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
int type: Added tests for the __rxor__
This commit is contained in:
@@ -4,9 +4,11 @@ assert x == 5
|
||||
|
||||
assert int.__doc__ == "int(x=0) -> integer\nint(x, base=10) -> integer\n\nConvert a number or string to an integer, or return 0 if no arguments\nare given. If x is a number, return x.__int__(). For floating point\nnumbers, this truncates towards zero.\n\nIf x is not a number or if base is given, then x must be a string,\nbytes, or bytearray instance representing an integer literal in the\ngiven base. The literal can be preceded by '+' or '-' and be surrounded\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\nBase 0 means to interpret the base from the string as an integer literal.\n>>> int('0b100', base=0)\n4"
|
||||
|
||||
|
||||
class A(int):
|
||||
pass
|
||||
|
||||
|
||||
x = A(7)
|
||||
assert x == 7
|
||||
assert type(x) is A
|
||||
@@ -18,3 +20,10 @@ assert int(-1).__bool__() == True
|
||||
assert int(0).__invert__() == -1
|
||||
assert int(-3).__invert__() == 2
|
||||
assert int(4).__invert__() == -5
|
||||
|
||||
assert int(0).__rxor__(0) == 0
|
||||
assert int(1).__rxor__(0) == 1
|
||||
assert int(0).__rxor__(1) == 1
|
||||
assert int(1).__rxor__(1) == 0
|
||||
assert int(3).__rxor__(-3) == -2
|
||||
assert int(3).__rxor__(4) == 7
|
||||
|
||||
Reference in New Issue
Block a user