/*****************************************************************
 ** @author   STF 409 (updated by STF 521)
 ** @version  0.0.2
 ** @purpose  1:20.2, Ensure that an altstep invocation works as expected and that the optional statement block is executed after the altstep staatement block (loopback case).
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

module Sem_2002_TheAltStatement_007 {

type port MyPort message {
	inout charstring
}

type component GeneralComp {
	port MyPort p;
	var boolean v_visitedAltstep := false;
}

template charstring m_testOne := "ping1";
template charstring m_testTwo := "ping2";

altstep a_test() runs on GeneralComp {
	[] p.receive(m_testOne) {
		v_visitedAltstep := true;
	}
}

testcase TC_Sem_2002_TheAltStatement_007() runs on GeneralComp {
	timer t_tmr := 0.5;
    t_tmr.start;
	p.send(m_testOne);
    t_tmr.timeout;  // wait for some time for the answer

	alt {
		[] a_test() {
			if (v_visitedAltstep == true) {
				setverdict(pass);
			}
		}
		[else] {
			setverdict(fail);
		}
	}

	setverdict(pass);
}

control {
	execute(TC_Sem_2002_TheAltStatement_007());
}

}