/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:22.2.2, applying @decoded to a forbidden field
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// When assigning individual fields of a message, encoded payload fields can be
// decoded prior to assignment using the @decoded modifier. In this case, the
// referenced field on the right hand sided of the assignment shall be one of the
// bitstring, hexstring, octetstring, charstring or universal charstring types. It
// shall be decoded into a value of the same type as the variable on the left hand
// side of the assignment.

module NegSem_220202_ReceiveOperation_005 {
	type record R
    {
        integer id,
        record of integer payload (0..255)
    }

	type port P message {
		inout R;
	}

    type component GeneralComp
	{
		port P p;
	}

    testcase TC_NegSem_220202_ReceiveOperation_005() runs on GeneralComp {
        var integer v_res with { encode "32bit" };
        p.send(R:{ id := 1, payload := {0, 0, 0, 0} });
        alt {
            [] p.receive(R:?) -> value (v_res := @decoded payload) {
                setverdict (pass);
            }
            [] p.receive { setverdict(pass); }
        }
    }

    control {
        execute(TC_NegSem_220202_ReceiveOperation_005(), 5.0);
    }
}