/*****************************************************************
 ** @author   STF 470
 ** @version  0.0.1
 ** @purpose  1:21.3.8, Verify that any from killed index redirection works for multidimensional arrays
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/
// The following requirements are tested:
// Restriction d:
// If the index redirection is used for multi-dimensional component arrays, the size
// of the integer array or record of integer type shall exactly be the same as the dimension
// of the respective array, and its type shall allow storing the highest index (from all
// dimensions) of the array.
module Sem_210308_killed_operation_010 {

    type component GeneralComp {}

	function f(float p_time) runs on GeneralComp {
		timer t := p_time;
		t.start;
		t.timeout;
		kill;
	}

    testcase TC_Sem_210308_killed_operation_010() runs on GeneralComp system GeneralComp {
		var boolean v_isRunning;
		const integer c_size := 3;
        var GeneralComp v_ptc[c_size][c_size];
		var integer v_index[2];
		timer t := 2.0;
		for (var integer i := 0; i < c_size; i := i + 1) {
			for (var integer j := 0; j < c_size; j := j + 1) {
				v_ptc[i][j] := GeneralComp.create alive; // created components are inactive
				if (i == 2 and j == 1) { v_ptc[i][j].start(f(1.0)); }
				else { v_ptc[i][j].start(f(100.0));} // activate v_ptc
			}
		}
        t.start;
		t.timeout;
        alt
		{
        	[] any from v_ptc.killed -> @index value v_index {
				if(v_index[0] == 2 and v_index[1] == 1){
		            setverdict(pass);
		        } else {
		            setverdict(fail, "Index incorrectly assigned");
		        }
			}
			[else] { setverdict(fail, "The any from killed operation didn't found killed component"); }
		}
    }

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