/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:22.3.5, multicast raise operation
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

// The following requirements are tested:
// Exceptions to one or more call operations may be sent to one, several or all peer entities
// connected to the addressed port. This can be specified in the same manner as described in
// clause 22.2.1. This means, the argument of the to clause of a raise operation is for
// unicast exceptions the address of one receiving entity, for multicast exceptions a list of
// addresses of a set of receivers and for broadcast exceptions the all component keywords.


module Sem_220305_raise_operation_004 {
	signature S() exception(integer);

	type port P procedure {
		inout S;
	}

    type component GeneralComp
	{
		port P p;
	}

	function f(integer p_expected) runs on GeneralComp
	{
        p.call(S:{}) {
            [] p.catch(S, p_expected) { setverdict(pass); }
            [] p.catch { setverdict(fail); }
        }
	}

    const integer c_ptcCount := 4;

    testcase TC_Sem_220305_raise_operation_004() runs on GeneralComp system GeneralComp {
        var GeneralComp v_ptcs[4];
        for (var integer i := 0; i < c_ptcCount; i := i + 1) {
            v_ptcs[i] := GeneralComp.create;
            connect(self:p, v_ptcs[i]:p);
            if (i mod 2 == 0) { v_ptcs[i].start(f(1)); }
            else { v_ptcs[i].start(f(2)); }
            p.getcall(S:?);
        }
		p.raise(S, 1) to (v_ptcs[0], v_ptcs[2] );
        p.raise(S, 2) to (v_ptcs[1], v_ptcs[3] );
        all component.done;
        setverdict(pass);
    }

    control {
        execute(TC_Sem_220305_raise_operation_004(), 5.0);
    }
}