コード例 #1
0
 def test_generate_random_with_variable_resolving_problem(self):
     m = robomachine.parse(_VAR_PROBLEM_MACHINE)
     out = StringIO()
     robomachine.generate(m,
                          max_actions=1,
                          output=out,
                          strategy=RandomStrategy)
     self.assertEqual(_TEST_VAR_PROBLEM_MACHINE, out.getvalue())
コード例 #2
0
def main():
    args = parser.parse_args()
    if args.input.endswith('.txt') and not args.output:
        sys.exit('txt input not allowed when no output')
    try:
        with open(args.input, 'r') as inp:
            machine = robomachine.parse(inp.read())
    except IOError, e:
        sys.exit(unicode(e))
コード例 #3
0
ファイル: runner.py プロジェクト: GLMeece/RoboMachine
def main():
    args = parser.parse_args()
    if args.input.endswith('.txt') and not args.output:
        sys.exit('txt input not allowed when no output')
    try:
        with open(args.input, 'r') as inp:
            machine = robomachine.parse(inp.read())
    except IOError, e:
        sys.exit(unicode(e))
コード例 #4
0
 def test_parsing(self):
     m = robomachine.parse(_MACHINA2)
     self.assertEqual(m.states[0].name, 'A')
     self.assertEqual(m.states[0].steps, ['  Foo  bar', '  Bar  foo'])
     self.assertEqual([a.name for a in m.states[0].actions], ['first', 'second', ''])
     self.assertEqual([a.next_state.name for a in m.states[0].actions], ['B', 'C', 'D'])
     self.assertEqual(m.states[1].name, 'B')
     self.assertEqual(m.states[1].steps, [])
     self.assertEqual([a.name for a in m.states[1].actions], ['something else', 'other thing'])
     self.assertEqual([a.next_state.name for a in m.states[1].actions], ['A', 'C'])
     self.assertEqual(m.states[2].name, 'C')
     self.assertEqual(m.states[2].steps, ['  No Operation  #This is a comment'])
     self.assertEqual(m.states[2].actions, [])
コード例 #5
0
 def test_parsing(self):
     m = robomachine.parse(_MACHINA2)
     self.assertEqual(m.states[0].name, 'A')
     self.assertEqual(m.states[0].steps, ['  Foo  bar', '  Bar  foo'])
     self.assertEqual([a.name for a in m.states[0].actions],
                      ['first', 'second', ''])
     self.assertEqual([a.next_state.name for a in m.states[0].actions],
                      ['B', 'C', 'D'])
     self.assertEqual(m.states[1].name, 'B')
     self.assertEqual(m.states[1].steps, [])
     self.assertEqual([a.name for a in m.states[1].actions],
                      ['something else', 'other thing'])
     self.assertEqual([a.next_state.name for a in m.states[1].actions],
                      ['A', 'C'])
     self.assertEqual(m.states[2].name, 'C')
     self.assertEqual(m.states[2].steps,
                      ['  No Operation  #This is a comment'])
     self.assertEqual(m.states[2].actions, [])
コード例 #6
0
 def test_parse_machina_state_steps(self):
     m = robomachine.parse(_MACHINA)
     self.assertEqual(['  Log  In Start State'], m.states[0].steps)
     self.assertEqual(['  Log  In End State'], m.states[1].steps)
コード例 #7
0
 def test_parse_machina_state_actions(self):
     m = robomachine.parse(_MACHINA)
     self.assertEqual(['Some keyword'], [a.name for a in m.states[0].actions])
     self.assertEqual([], [a.name for a in m.states[1].actions])
コード例 #8
0
 def test_parse_machina_state_names(self):
     m = robomachine.parse(_MACHINA)
     self.assertEqual(['Start State', 'End State'], [s.name for s in m.states])
コード例 #9
0
 def test_generate_random_with_variable_resolving_problem(self):
     m = robomachine.parse(_VAR_PROBLEM_MACHINE)
     out = StringIO()
     robomachine.generate(m, max_actions=1, output=out, strategy=RandomStrategy)
     self.assertEqual(_TEST_VAR_PROBLEM_MACHINE, out.getvalue())
コード例 #10
0
 def test_generate_all_dfs_max_actions_2(self):
     m = robomachine.parse(_MACHINA2)
     out = StringIO()
     robomachine.generate(m, max_actions=2, output=out)
     self.assertEqual(_TESTS2_GENERATE_ALL_DFS_MAX_ACTIONS_2, out.getvalue())
コード例 #11
0
 def test_invalid_state_parsing(self):
     try:
         m = robomachine.parse(_INVALID_STATE_MACHINE)
         self.fail('Should raise exception')
     except RoboMachineParsingException:
         pass
コード例 #12
0
 def test_parse_machina_state_steps(self):
     m = robomachine.parse(_MACHINA)
     self.assertEqual(['  Log  In Start State'], m.states[0].steps)
     self.assertEqual(['  Log  In End State'], m.states[1].steps)
コード例 #13
0
 def test_parse_machina_state_actions(self):
     m = robomachine.parse(_MACHINA)
     self.assertEqual(['Some keyword'],
                      [a.name for a in m.states[0].actions])
     self.assertEqual([], [a.name for a in m.states[1].actions])
コード例 #14
0
 def test_parse_machina_state_names(self):
     m = robomachine.parse(_MACHINA)
     self.assertEqual(['Start State', 'End State'],
                      [s.name for s in m.states])
コード例 #15
0
 def test_generate_all_dfs_max_actions_2(self):
     m = robomachine.parse(_MACHINA2)
     out = StringIO()
     robomachine.generate(m, max_actions=2, output=out)
     self.assertEqual(_TESTS2_GENERATE_ALL_DFS_MAX_ACTIONS_2,
                      out.getvalue())
コード例 #16
0
 def test_invalid_state_parsing(self):
     try:
         m = robomachine.parse(_INVALID_STATE_MACHINE)
         self.fail('Should raise exception')
     except RoboMachineParsingException:
         pass