예제 #1
0
 def test_jump_condition_true(self):
     env = BFEnvironment()
     bf_command_companion, bf_command_no_jump = BFBranchCommand(
         env, no_jump=1), BFCommand(env, next=2)
     env.current_cell = 1
     b_command = BFBranchCommand(env,
                                 companion=bf_command_companion,
                                 no_jump=bf_command_no_jump)
     self.assertEqual(b_command.next, 1)
예제 #2
0
 def test_next_true_command(self):
     env = BFEnvironment()
     bf_command_companion, bf_command_no_jump = OpenBranchCommand(
         env, no_jump=1), BFCommand(env, next=2)
     env.current_cell = 1
     cb_command = ClosingBranchCommand(env,
                                       companion=bf_command_companion,
                                       no_jump=bf_command_no_jump)
     self.assertEqual(cb_command.next, 1)
예제 #3
0
 def test_operator_execute_does_nothing(self):
     command = BFCommand(None)
     command.execute()
예제 #4
0
 def test_operator_repr(self):
     command_1 = BFCommand(None, operator='test')
     self.assertEqual(repr(command_1), 'test')
예제 #5
0
 def test_next(self):
     command_1 = BFCommand(None, next=None)
     command_2 = BFCommand(None, next=None)
     command_1.next = command_2
     self.assertEqual(command_1.next, command_2)
예제 #6
0
 def build_ast(self):
     if not self.code:
         return BFCommand(self.env)
     pre_ast = self._pre_build_ast()
     ast = self._chain_ast(pre_ast)
     return ast