/***************************************************
 ** @author   STF 487 (changed to positive by STF 572)
 ** @version  0.0.2
 ** @purpose  1:20.5.2, local timer (referenced through timer parameter) as a parameter of activated altstep in module control
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// In TTCN-3:2018 and earlier versions of the core language standard, there was
// a restriction on control timers:
// For altsteps activated in module control or in functions or altsteps invoked
// directly or indirectly from module control, all timer instances in the actual
// parameter list shall be declared in the highest scope of the module control
// part (see clause 26.2). Timers from lower scopes of the module control part
// (i.e. from the nested statement blocks) are not allowed to occur in the actual
// parameter list.
//
// The restriction is no longer present and timers from lower scopes can be used
// as actual parameters.

module Sem_200502_the_activate_operation_009 {

	type port P message {
		inout integer;
	}

	type component GeneralComp {
		port P p;
	}

	altstep a(timer t_tmr) {
		[] t_tmr.timeout { log ("Timeout in default"); }
	}

	testcase TC_Sem_200502_the_activate_operation_009() runs on GeneralComp {
        setverdict(pass);
	}

    function f_activate(timer t_tmr) {
        activate(a(t_tmr));
    }

    function f_test() {
        timer t_tmr := 1.0;
        t_tmr.start;
        f_activate(t_tmr); // t_tmr is a local timer, this should lead to an activation error in f_activate
    }

	control{
        timer t_tmr2;
        f_test();
        alt {
            [] t_tmr2.timeout { }
        }
		execute(TC_Sem_200502_the_activate_operation_009());
	}
}
