/***************************************************
 ** @author   STF 521
 ** @version  0.0.1
 ** @purpose  1:16.1.4, verify that the component.stop operation cannot be used in a function called during receiving operation (as actual parameters)
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// If value returning functions are called in receiving communication operations (in templates, template fields,
// in-line templates, or as actual parameters), in guards or events of alt statements or altsteps (see clause 20.2),
// or in initializations of altstep local definitions (see clause 16.2), the following operations shall not be
// used in functions called in the cases specified above, in order to avoid side effects that cause changing the
// state of the component or the actual snapshot and to prevent different results of subsequent evaluations
// on an unchanged snapshot:
// a) All component operations, i.e. create, start (component), stop (component), kill, running (component),
// alive, done and killed (see notes 1, 3, 4 and 6).

module NegSem_160104_invoking_functions_from_specific_places_132 {
	type record R {
		integer field1
	}

    type port P message {
        inout R;
    }

    type component GeneralComp {
        port P p;
	}

    function f_ptcBehaviour() runs on GeneralComp {
        timer t_tmr := 10.0;
		t_tmr.start;
		t_tmr.timeout;
    }

	function f_test(GeneralComp p_ptc) return template integer {
		p_ptc.stop;
        return ?;
	}

 	template R m_msg (template integer p_par) := {
		field1 := p_par
	}

    testcase TC_NegSem_160104_invoking_functions_from_specific_places_132() runs on GeneralComp system GeneralComp {
        var GeneralComp v_ptc := GeneralComp.create;
		v_ptc.start(f_ptcBehaviour());
        connect(mtc:p, mtc:p);
        p.send(R:{ field1 := 1 });
        p.receive(m_msg(f_test(v_ptc)));
		setverdict(pass);
	}

	control {
		execute(TC_NegSem_160104_invoking_functions_from_specific_places_132());
	}
}
