/***************************************************
 ** @author   STF 572
 ** @version  0.0.1
 ** @purpose  1:5.4.2, verify that a non-deterministic external function call cannot be used during evaluation of a deterministic fuzzy parameter
 ** @verdict  pass reject
 ** @configuration  external_functions
 ***************************************************/

// The following requirement is tested:
// Actual parameters passed to fuzzy or lazy formal parameters shall fulfill the restrictions imposed on content
// of functions used in special places given in 16.1.4.
// The following operations shall not be used:
// e) Calling non-deterministic external functions, i.e. external functions where the resulting values for actual
// inout or out parameters or the return value may differ for different invocations with the same actual in and
// inout parameters (see notes 4 and 6).

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

    type component GeneralComp {
        port P p;
	}

	/**
	 * @return always true
	 */
    external function xf_NegSem_050402_actual_parameters_001() return boolean;

	function f_test() runs on GeneralComp return template integer {
		if (xf_NegSem_050402_actual_parameters_001()) { return ?; }
		else { return 1; }
	}

    function f_param(template @fuzzy @deterministic integer p_param) runs on GeneralComp  {
        log(p_param); // causes validation
    }

    testcase TC_NegSem_050402_actual_parameters_221() runs on GeneralComp system GeneralComp {
        f_param(f_test());
		setverdict(pass);
	}

	control {
		execute(TC_NegSem_050402_actual_parameters_221());
	}
}
