OpenTTCN/Tutorials/Using odb, the command-line debugger/main.ttcn

From OpenTTCN

Jump to: navigation, search
module ModMain
{

type component CompType
{
    var charstring compVar := "Supplied value #1";
}

function RecursiveFactorial(integer arg) return integer
{
    if (arg < 0)
    {
        log("RecursiveFactorial(): invalid argument.");
        setverdict(fail);
        stop;
    }
    else if (arg == 0)
    {
        return 1;
    }

    var integer f := RecursiveFactorial(arg - 1);
    return arg * f;
}

testcase TC_Recursive() runs on CompType
{
    var integer n := 5;

    log(RecursiveFactorial(n));
    log(RecursiveFactorial(3));
    log(RecursiveFactorial(2));
    log(RecursiveFactorial(1));

    setverdict(pass);
}

}
Views
Personal tools