/******************************************************************************
 * 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.2, verify that error is generated when passing union and its sub-element to inout parameters
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// Whenever a value or template of a record, set, union, record of, set of, array 
// and anytype type is passed as an actual parameter to an inout parameter, none of 
// the fields or elemens of this structured value or template shall be passed as 
// an actual parameter to another inout parameter of the same parameterized TTCN-3 
// object. This restriction applies recursively to all sub-elements of the structured
// value or template in any level of nesting.

module NegSem_050402_actual_parameters_138 { 

    type component GeneralComp {
	}
    
    type record Sub {
        integer subfield1
    }

    type union U {
        Sub option1,
        charstring option2
    }
    
    function f_test (inout integer p_val, inout U p_un) {
        p_un.option1.subfield1 := 10;
        if (p_val == 10) { setverdict(pass); }
        else { setverdict(fail); }
    }

    testcase TC_NegSem_050402_actual_parameters_138() runs on GeneralComp {
        var U v_val := { option1 := { subfield1 := 1 } }; 
        f_test(v_val.option1.subfield1, v_val);
	}

	control {
		execute(TC_NegSem_050402_actual_parameters_138());
	}
}
