/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:15.6.5, Ensure that template variables allow referencing with an Anyvalue union template
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

//Restriction a)
/*When referencing an alternative of a union template or template field to which AnyValueOrNone or omit is
assigned, at the left hand side of an assignment, the template field is implicitly set to be present and the
referenced alternative becomes the chosen one.*/

module Sem_150605_Referencing_union_alternatives_004 {

    type union My_Union {
        integer   u1,
        float     u2
    }

    type record ExampleType {	// Exampletype record with union
	    integer a,
	    My_Union b optional
       }

    type port loopbackPort message{inout ExampleType};


    type component GeneralComp {
	  port loopbackPort messagePort
    }


    testcase TC_Sem_150605_Referencing_union_alternatives_004() runs on GeneralComp {





    var template ExampleType m_template;
    var template ExampleType m_template_2;

    //assign values to template:

		m_template.a:=10;
		m_template.b := omit;

		m_template_2 := m_template;

		m_template_2.b.u1:=1;


      if (match(valueof(m_template_2),{a := 10,b :={u1 := 1}}))
	    {
		setverdict(pass,m_template_2);
	} else {
		setverdict(fail,m_template_2);
	}

 }

    control{
        execute(TC_Sem_150605_Referencing_union_alternatives_004());
    }
}