/*****************************************************************
 ** @author   STF 521
 ** @version  0.0.1
 ** @purpose  1:22.3.1, verify that forbidden functions cannot appear in response and exception handling part guards
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// i) The evaluation of the Boolean expressions guarding the alternatives in the response
// and exception handling part may have side effects. In order to avoid unexpected side
// effects, the same rules as for the Boolean guards in alt statements shall be applied
// (see clause 20.2).

module NegSem_220301_CallOperation_017 {

	signature S();

	type port P procedure {
		inout S;
	}

    type component GeneralComp {
		port P p;
		var integer v_int := 0;
	}

	function f_called() runs on GeneralComp {
		p.getcall(S:?);
		p.reply(S:{});
	}

	function f_guard() runs on GeneralComp return boolean {
		v_int := v_int + 1;
		return v_int < 10;
	}

    testcase TC_NegSem_220301_CallOperation_017() runs on GeneralComp system GeneralComp {
        var GeneralComp v_ptc := GeneralComp.create;
		connect(self:p, v_ptc:p);
		v_ptc.start(f_called());
		p.call(S:{}) {
			[f_guard()] p.getreply(S:?) { setverdict(pass, "Reply accepted"); } // guard error expected
		}
    }

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