def test_jump_if_true_doesnt(self): parameters = [MockParameter(0), MockParameter(39)] operation = self._operation_factory.create_operation( OperationCode.JUMP_IF_TRUE) operation.execute(parameters, None, None) self.assertEqual(12, operation.get_new_pointer(9))
def test_jump_if_false_jumps(self): parameters = [MockParameter(0), MockParameter(39)] operation = self._operation_factory.create_operation( OperationCode.JUMP_IF_FALSE) operation.execute(parameters, None, None) self.assertEqual(39, operation.get_new_pointer(9))
def test_halt_operation(self): parameters = [MockParameter(11), MockParameter(7), MockParameter(0)] operation = self._operation_factory.create_operation(OperationCode.END) operation.execute(parameters, None, None) self.assertEqual(None, parameters[0].set_value) self.assertEqual(None, parameters[1].set_value) self.assertEqual(None, parameters[2].set_value)
def test_equals_operation_if_greater(self): parameters = [ MockParameter(1231), MockParameter(231), MockParameter(23) ] operation = self._operation_factory.create_operation( OperationCode.EQUALS) operation.execute(parameters, None, None) self.assertEqual(0, parameters[2].set_value)
def test_less_than_operation_if_equal(self): parameters = [ MockParameter(231), MockParameter(231), MockParameter(23) ] operation = self._operation_factory.create_operation( OperationCode.LESS_THAN) operation.execute(parameters, None, None) self.assertEqual(0, parameters[2].set_value)
def test_output_operation(self): parameters = [MockParameter(7)] output = LastOutput() operation = self._operation_factory.create_operation( OperationCode.OUTPUT) operation.execute(parameters, None, output) self.assertEqual(7, output)
def test_input_operation(self): parameters = [MockParameter(4)] input = SingleInput(17) operation = self._operation_factory.create_operation( OperationCode.INPUT) operation.execute(parameters, input, None) self.assertEqual(17, parameters[0].set_value)