/******************************************************************************
 * Copyright (c) ETSI 2017.
 *
 * This file is subject to copyrights owned by ETSI. Non-exclusive permission
 * is hereby granted, free of charge, to copy, reproduce and amend this file
 * under the following conditions: It is provided "as is", without warranty of any
 * kind, expressed or implied.
 * 
 * ETSI shall never be liable for any claim, damages, or other liability arising
 * from its use or inability of use.This permission does not apply to any documentation
 * associated with this file for which ETSI keeps all rights reserved. The present
 * copyright notice shall be included in all copies of whole or part of this
 * file and shall not imply any sub-license right.
 *
 * Modified by: Adrien Kirjak
 *
 ** @version  0.0.1
 ** @purpose  1:5.4.1, verify that fuzzy parameter passed to lazy formal parameter enables lazy evaluation
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// Lazy and fuzzy properties are valid only in the scope, where the parameters' names are visible. 
// For example, if a fuzzy parameter is passed to a formal parameter declared without a modifier, it 
// loses its fuzzy feature inside the called function. Similarly, if it is passed to a lazy formal 
// parameter, it becomes lazy within the called function.

module Sem_050401_top_level_029 { 

	type component GeneralComp {
        var integer vc_int := 20;
	}

    function fx(@lazy integer p_int) runs on GeneralComp {
        vc_int := 0; // p_int hasn't been evaluated yet - this change will have impact on evaluation
        if (p_int == 1) { setverdict(pass); }
        else { setverdict(fail); }
        vc_int := 10; // no impact on p_int value as the parameter has been already evaluated
        if (p_int == 1) { setverdict(pass); }
        else { setverdict(fail); }
    }
	function f(@fuzzy integer p_int) runs on GeneralComp {
        fx(p_int); // no evaluation of the value yet
	}
	
	testcase TC_Sem_050401_top_level_029() runs on GeneralComp {
		f(vc_int + 1); // vc_int is equal to 20 at the time of function call
	}

	control{
		execute(TC_Sem_050401_top_level_029());
	}
}
