Tests for bound method edge cases
This commit is contained in:
parent
2e7bf54d9a
commit
48f9d34a9b
31
test/testBoundMethodEdgecases.krk
Normal file
31
test/testBoundMethodEdgecases.krk
Normal file
@ -0,0 +1,31 @@
|
||||
class Callable():
|
||||
def __init__(self,name):
|
||||
self.name = name
|
||||
def __str__(self):
|
||||
return f'<Callable {self.name}>'
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
def __call__(self, *args):
|
||||
print('callable',self,'received',args)
|
||||
|
||||
class Foo():
|
||||
c = Callable
|
||||
def __str__(self):
|
||||
return f'<Foo instance>'
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
if True:
|
||||
let c = Callable('c')
|
||||
let f = Foo()
|
||||
let m = method(c,f)
|
||||
m()
|
||||
print(c,f,m)
|
||||
|
||||
let n = method(Foo.c('Foo.c()'),f)
|
||||
n()
|
||||
print(c,f,m,n)
|
||||
|
||||
m = method(method(method(print,'a'),'b'),'c')
|
||||
m()
|
||||
print(c,f,m)
|
6
test/testBoundMethodEdgecases.krk.expect
Normal file
6
test/testBoundMethodEdgecases.krk.expect
Normal file
@ -0,0 +1,6 @@
|
||||
callable <Callable c> received [<Foo instance>]
|
||||
<Callable c> <Foo instance> <bound method ? of <Foo instance>>
|
||||
callable <Callable Foo.c()> received [<Foo instance>]
|
||||
<Callable c> <Foo instance> <bound method ? of <Foo instance>> <bound method ? of <Foo instance>>
|
||||
a b c
|
||||
<Callable c> <Foo instance> <bound method ? of 'c'>
|
Loading…
Reference in New Issue
Block a user