mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Add a test to verify that bound methods work correctly.
This commit is contained in:
parent
f95dd0a298
commit
b5a136b05d
1 changed files with 18 additions and 0 deletions
|
@ -847,6 +847,23 @@ def overloading():
|
||||||
del a[0:10]
|
del a[0:10]
|
||||||
verify(a.delslice == (0, 10))
|
verify(a.delslice == (0, 10))
|
||||||
|
|
||||||
|
def methods():
|
||||||
|
if verbose: print "testing methods..."
|
||||||
|
class C(object):
|
||||||
|
def __init__(self, x):
|
||||||
|
self.x = x
|
||||||
|
def foo(self):
|
||||||
|
return self.x
|
||||||
|
c1 = C(1)
|
||||||
|
verify(c1.foo() == 1)
|
||||||
|
class D(C):
|
||||||
|
boo = C.foo
|
||||||
|
goo = c1.foo
|
||||||
|
d2 = D(2)
|
||||||
|
verify(d2.foo() == 2)
|
||||||
|
verify(d2.boo() == 2)
|
||||||
|
verify(d2.goo() == 2)
|
||||||
|
|
||||||
def all():
|
def all():
|
||||||
lists()
|
lists()
|
||||||
dicts()
|
dicts()
|
||||||
|
@ -873,6 +890,7 @@ def all():
|
||||||
newslot()
|
newslot()
|
||||||
altmro()
|
altmro()
|
||||||
overloading()
|
overloading()
|
||||||
|
methods()
|
||||||
|
|
||||||
all()
|
all()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue