/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:6.2.1.1, verify that optional fields are created and uninitialized when expanding uninitialized record values (explicit omit)
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirement is tested:
// When referencing a field of an uninitialized record value or field or omitted field
// (including omitting a field at a higher level of the embedding hierarchy) on the left
// hand side of an assignment, the reference shall recursively be expanded up to and
// including the depth of the referenced subfield as follows:
// a) When expanding a value or value field of record type, the subfield referenced in
// the dot notation shall be set to present and all unreferenced mandatory subfields shall
// be left uninitialized; when the assignment is used in a scope where the optional
// attribute is equal to "explicit omit", all unreferenced optional subfields shall be
// left undefined. When the assignment is used in a scope where the optional attribute is
// equal to "implicit omit", all unreferenced optional subfields shall be set to omit.
// b) Expansion of record of/set of/array, union and set values and intermediate fields
// shall follow the rules of item a) in clauses 6.2.3 and 6.2.5.1, and clause 6.2.2.1
// correspondingly.
// At the end of the expansion, the value at the right hand side of the assignment shall
// be assigned to the referenced subfield.

module Sem_06020101_ReferencingRecordFields_009 {

    type component GeneralComp {
    }

    type record R {
        integer field1 optional,
        charstring field2
    }

    testcase TC_Sem_06020101_ReferencingRecordFields_009() runs on GeneralComp {
        var R v_rec;
        v_rec.field2 := "abc";
        if (isbound(v_rec) and not isbound(v_rec.field1)) {
	        setverdict(pass);
        } else {
	        setverdict(fail);
        }
    }

    control {
        execute(TC_Sem_06020101_ReferencingRecordFields_009());
    }

}
