Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Dec 19, 2015
1 parent f5c37d1 commit 90249b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sismic/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def __repr__(self):
return '{}[{}]({})'.format(self.__class__.__name__, self._statechart, ', '.join(self.configuration))


def run_in_background(interpreter: Interpreter, delay: int=0.2):
def run_in_background(interpreter: Interpreter, delay: float=0.2):
"""
Run given interpreter in background. The time is updated according to
``time.time()``. The interpreter is ran until it reachs a final configuration.
Expand Down
16 changes: 13 additions & 3 deletions tests/test_interpreter.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import unittest
from sismic import io
from sismic.interpreter import Interpreter
from sismic.interpreter import Interpreter, run_in_background
from sismic.evaluator import DummyEvaluator
from sismic.model import Event, Transition, StateChart, StateMixin

from sismic.model import PreconditionFailed, PostconditionFailed, InvariantFailed


class SimulatorSimpleTest(unittest.TestCase):
class RunInBackgroundTests(unittest.TestCase):
def test_run_in_background(self):
sc = io.import_from_yaml(open('examples/simple/simple.yaml'))
intp = Interpreter(sc)
task = run_in_background(intp, 0.001)
intp.send(Event('goto s2'))
intp.send(Event('goto final'))
task.join()
self.assertTrue(intp.final)


class SimulatorSimpleTests(unittest.TestCase):
def test_init(self):
sc = io.import_from_yaml(open('examples/simple/simple.yaml'))
interpreter = Interpreter(sc, DummyEvaluator)
Expand Down

0 comments on commit 90249b3

Please sign in to comment.