def main(): try: fsm = parse("../sample.fsml") sampleInput = json.load(open("./sample.input", "r")) # just for visualization of the fsm dict (not needed anywhere in the code) jsonFile = open("./sample.json", 'w') jsonFile.write(json.dumps(fsm)) # check the ok constraints ok(fsm) #simulate the fsm output = simulate(fsm, sampleInput) # dump the simulation output to file outFile = open("./sample.output", 'w') outFile.write(json.dumps(output)) #generate Code generateCode(fsm) #draw fsm draw(fsm).write("dot/sample.dot") except FsmlException: raise
def testSimulationOutput(self): # load the base line output correctJsonOutput = json.load(open("tests/baselines/sample.output")) # produce the output of the generated modules generatedJsonOutput = self.stepper.simulate(self.input) # produce the output of the hand-written simulator module simulatedJsonOutput = simulate(self.fsm, self.input) # assert all 3 types of output are equal self.assertEqual(correctJsonOutput, simulatedJsonOutput) self.assertEqual(correctJsonOutput, generatedJsonOutput)