mirror of
https://github.com/godotengine/buildroot.git
synced 2026-01-05 14:09:53 +03:00
support/testing: add python-automat tests
Use a minimal script to check the basic usage by creating and using a small state machine. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
367c045512
commit
66f99555ed
27
support/testing/tests/package/sample_python_automat.py
Normal file
27
support/testing/tests/package/sample_python_automat.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from automat import MethodicalMachine
|
||||
|
||||
|
||||
class Led(object):
|
||||
_machine = MethodicalMachine()
|
||||
|
||||
@_machine.state()
|
||||
def led_on(self):
|
||||
"led is on"
|
||||
|
||||
@_machine.state(initial=True)
|
||||
def led_off(self):
|
||||
"led is off"
|
||||
|
||||
@_machine.input()
|
||||
def turn_on(self):
|
||||
"turn the led on"
|
||||
|
||||
@_machine.output()
|
||||
def _light(self):
|
||||
print("light")
|
||||
|
||||
led_off.upon(turn_on, enter=led_on, outputs=[_light])
|
||||
|
||||
|
||||
led = Led()
|
||||
led.turn_on()
|
||||
Reference in New Issue
Block a user