exponenta event banner

addConditionsFrom

Класс: matlab.unittest.diagnostics.ConstraintDiagnostic
Пакет: matlab.unittest.diagnostics

Добавить условие из другого ConstraintDiagnostic в список условий

Синтаксис

addConditionsFrom(constDiag, otherConstDiag)

Описание

addConditionsFrom(constDiag, otherConstDiag) добавляет условия из ConstraintDiagnostic экземпляр, constDiag, в список условий в Diagnostic экземпляр, diag. Это полезно, когда зависимости составляют другое ограничение и необходимо использовать условия, созданные при диагностике составленного ограничения.

Входные аргументы

constDiag

Диагностика для добавления условий, указанных как matlab.unittest.diagnostics.ConstraintDiagnostic случай

otherConstDiag

Диагностика для добавления условий из, указанная как matlab.unittest.diagnostics.ConstraintDiagnostic случай

Примеры

развернуть все

% This demonstrates a constraint that composes another constraint
% and uses the addConditionsFrom method to utilize the conditions
% from the composed ConstraintDiagnostic.
classdef IsDouble < matlab.unittest.constraints.Constraint
    
    properties(Constant, GetAccess=private)
        DoubConst = matlab.unittest.constraints.IsInstanceOf(?double);
    end
    
    methods
        function tf = satisfiedBy(constraint, actual)
            tf = constraint.DoubConst.satisfiedBy(actual);
        end
        function diag = getDiagnosticFor(constraint, actual)
            diag = ConstraintDiagnostic;
            
            % Now add conditions from the IsInstanceOf
            % Diagnostic
            otherDiag = constraint.DoubConst.getDiagnosticFor(actual);
            diag.addConditionsFrom(otherDiag)
            
            % ...
        end
    end
end

См. также