/*****************************************************************
 ** @author   STF 409
 ** @version  0.0.1
 ** @purpose  1:20.2, Ensure that activated defaults are processed in the reverse order (loopback case).
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

module Sem_2002_TheAltStatement_004 {

type port MyPort message {
    inout charstring
}

type component GeneralComp {
    port MyPort p;
}

template charstring m_testOne := "ping1";
template charstring m_testTwo := "ping2";
template charstring m_testThree := "ping3"; // never sent!

altstep a_first() runs on GeneralComp {
    [] p.receive(m_testTwo) {
        setverdict(fail);
    }
}

altstep a_second() runs on GeneralComp {
    [] p.receive(m_testOne) {
        setverdict(pass);
    }
}

testcase TC_Sem_2002_TheAltStatement_004() runs on GeneralComp {
    var default v_defaultOne := activate(a_first());
    var default v_defaultTwo := activate(a_second());

    p.send(m_testOne);
    p.send(m_testTwo);

    alt {
        [] p.receive(m_testThree) {
            setverdict(fail);
        }
    }
}

control {
    execute(TC_Sem_2002_TheAltStatement_004(), 2.0);  // if the altstep isn't handled after 2s, we raise an error
}

}