Skip to content

matlab/agent-skills-playground / demos/requirements-based-verification/skills/simulink-test-sequence-from-ears

simulink-test-sequence-from-ears

Verified

Generate Simulink Test Sequence blocks and harnesses from EARS requirements. Use when asked to create a test case from a requirement, generate tests from a .slreqx file, or verify a Simulink model with requirement-based tests.

scripts/addPreconditionSteps.m

View on GitHub
function lastStep = addPreconditionSteps(blockPath, stepPrefix, anchorStep, preconditionSteps)
%ADDPRECONDITIONSTEPS Insert optional precondition steps into a Test Sequence.
%   LASTSTEP = addPreconditionSteps(BLOCKPATH, STEPPREFIX, ANCHORSTEP,
%   PRECONDITIONSTEPS) adds each precondition step after ANCHORSTEP and
%   returns the final step name for subsequent chaining.

    lastStep = anchorStep;
    if nargin < 4 || isempty(preconditionSteps)
        return;
    end

    for i = 1:numel(preconditionSteps)
        if isfield(preconditionSteps(i), 'name') && strlength(string(preconditionSteps(i).name)) > 0
            stepName = [stepPrefix '_' regexprep(char(preconditionSteps(i).name), '\W', '_')];
        else
            stepName = sprintf('%s_Precondition%d', stepPrefix, i);
        end

        action = "";
        if isfield(preconditionSteps(i), 'action')
            action = string(preconditionSteps(i).action);
        end
        duration = 0.2;
        if isfield(preconditionSteps(i), 'duration') && ~isempty(preconditionSteps(i).duration)
            duration = preconditionSteps(i).duration;
        end

        sltest.testsequence.addStepAfter(blockPath, stepName, lastStep, ...
            'Action', sprintf('%% Precondition step %d\n\n%s', i, action));
        sltest.testsequence.addTransition(blockPath, lastStep, ...
            sprintf('after(%g, sec)', duration), stepName);
        lastStep = stepName;
    end
end
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall