mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Get rid of most of the rest of coerce (slot is still there for now).
This commit is contained in:
parent
79212998a8
commit
4886cc331f
19 changed files with 131 additions and 497 deletions
|
@ -2567,33 +2567,6 @@ def rich_comparisons():
|
|||
verify(eval("x %s c[y]" % op) == eval("x %s y" % op),
|
||||
"x=%d, y=%d" % (x, y))
|
||||
|
||||
def coercions():
|
||||
if verbose: print "Testing coercions..."
|
||||
class I(int): pass
|
||||
coerce(I(0), 0)
|
||||
coerce(0, I(0))
|
||||
class L(long): pass
|
||||
coerce(L(0), 0)
|
||||
coerce(L(0), 0L)
|
||||
coerce(0, L(0))
|
||||
coerce(0L, L(0))
|
||||
class F(float): pass
|
||||
coerce(F(0), 0)
|
||||
coerce(F(0), 0L)
|
||||
coerce(F(0), 0.)
|
||||
coerce(0, F(0))
|
||||
coerce(0L, F(0))
|
||||
coerce(0., F(0))
|
||||
class C(complex): pass
|
||||
coerce(C(0), 0)
|
||||
coerce(C(0), 0L)
|
||||
coerce(C(0), 0.)
|
||||
coerce(C(0), 0j)
|
||||
coerce(0, C(0))
|
||||
coerce(0L, C(0))
|
||||
coerce(0., C(0))
|
||||
coerce(0j, C(0))
|
||||
|
||||
def descrdoc():
|
||||
if verbose: print "Testing descriptor doc strings..."
|
||||
def check(descr, what):
|
||||
|
@ -3961,11 +3934,8 @@ def notimplemented():
|
|||
('__and__', 'x & y', 'x &= y'),
|
||||
('__or__', 'x | y', 'x |= y'),
|
||||
('__xor__', 'x ^ y', 'x ^= y'),
|
||||
('__coerce__', 'coerce(x, y)', None)]:
|
||||
if name == '__coerce__':
|
||||
rname = name
|
||||
else:
|
||||
rname = '__r' + name[2:]
|
||||
]:
|
||||
rname = '__r' + name[2:]
|
||||
A = metaclass('A', (), {name: specialmethod})
|
||||
B = metaclass('B', (), {rname: specialmethod})
|
||||
a = A()
|
||||
|
@ -4043,7 +4013,6 @@ def test_main():
|
|||
str_subclass_as_dict_key()
|
||||
classic_comparisons()
|
||||
rich_comparisons()
|
||||
coercions()
|
||||
descrdoc()
|
||||
setclass()
|
||||
setdict()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue