/***************************************************
 ** @author   STF 470
 ** @version  0.0.1
 ** @purpose  1:20.5.1, verify break command behaviour in invoked default
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// If the execution of the selected top alternative of the default ends with a break statement
// the control flow of the test component will continue immediately after the alt statement.

module Sem_200501_the_default_mechanism_007 {

	type port P message {
		inout integer;
	}

	type component GeneralComp {
		var integer vc_messageCounter := 0;
		port P p;
	}

	altstep a() runs on GeneralComp {
		[] p.receive(integer:?) {
			vc_messageCounter := vc_messageCounter + 1;
			if (vc_messageCounter == 2) {
				setverdict(pass, "Message count full, terminating alt");
				break;
			}
			setverdict(pass, "Default value -> repeating alt");
			repeat;
		}
	}

	testcase TC_Sem_200501_the_default_mechanism_007() runs on GeneralComp {
		activate(a());
		p.send(integer:5);
		p.send(integer:0);
		p.send(integer:1);
		alt {
			[] p.receive(integer:1) { // not expected: break should occur first
				vc_messageCounter := vc_messageCounter + 1;
				setverdict(fail);
			}
		}
		if (vc_messageCounter != 2) {
			setverdict(fail, "Different number of received messages (", vc_messageCounter, ") than expected (2)");
		}
	}

	control{
		execute(TC_Sem_200501_the_default_mechanism_007());
	}
}
