2018-02-24 12:13:42 +00:00
|
|
|
# test calling a subclass of a native class that supports calling
|
|
|
|
|
|
|
|
# For this test we need a native class that can be subclassed (has make_new)
|
|
|
|
# and is callable (has call). The only one available is machine.Signal, which
|
|
|
|
# in turns needs PinBase.
|
|
|
|
try:
|
2022-08-18 07:57:45 +01:00
|
|
|
import machine
|
2018-02-24 12:13:42 +00:00
|
|
|
machine.PinBase
|
|
|
|
machine.Signal
|
2019-04-28 13:12:17 +01:00
|
|
|
except:
|
2018-02-24 12:13:42 +00:00
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
class Pin(machine.PinBase):
|
|
|
|
#def __init__(self):
|
|
|
|
# self.v = 0
|
|
|
|
|
|
|
|
def value(self, v=None):
|
|
|
|
return 42
|
|
|
|
|
|
|
|
class MySignal(machine.Signal):
|
|
|
|
pass
|
|
|
|
|
|
|
|
s = MySignal(Pin())
|
|
|
|
|
|
|
|
# apply call to the subclass, which should call the native base
|
|
|
|
print(s())
|