/***************************************************
 ** @author   STF 521
 ** @version  0.0.1
 ** @purpose  1:16.1.4, verify that the reply operation cannot be used in guards of alt statements
 ** @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:
// b) All port operations, i.e. start (port), stop (port), halt, clear, checkstate, send, receive, trigger, call,
// getcall, reply, getreply, raise, catch, check, connect, disconnect, map and unmap (see notes 1, 2, 3, 4 and 6).

module NegSem_160104_invoking_functions_from_specific_places_191 {
    type port P message {
        inout integer;
    }

	signature S();

	type port PSig procedure {
        inout S;
    }

    type component GeneralComp {
        port P p;
		port PSig psig;
	}

	function f_ptcBehaviour() runs on GeneralComp {
		psig.call(S:{}, nowait);
	}

	function f_test() runs on GeneralComp return boolean {
		psig.reply(S:{});
        return true;
	}

    testcase TC_NegSem_160104_invoking_functions_from_specific_places_191() runs on GeneralComp system GeneralComp {
		var GeneralComp v_ptc := GeneralComp.create;
        connect(mtc:p, mtc:p);
		connect(mtc:psig, v_ptc:psig);
		v_ptc.start(f_ptcBehaviour());
        p.send(1);
		psig.getcall(S:?);
		alt {
            [f_test()] p.receive(integer:?) {}
        }
		setverdict(pass);
	}

	control {
		execute(TC_NegSem_160104_invoking_functions_from_specific_places_191());
	}
}
