/***************************************************
 ** @author   STF 409
 ** @version  0.0.1
 ** @purpose  1:B.1.3.3, Ensure that the IUT correctly handles template matching of ? symbols in value elements
 ** @verdict  pass reject
 ***************************************************/

module NegSem_B010303_permutation_001 {
	type record MessageType {
		set of integer field1,
		// permutation can only be applied to a record of type
		set of integer field2,
		set of integer field3,
		set of integer field4
	}

	type port loopbackPort message {
		inout MessageType;
	}


	type component GeneralComp {
		port loopbackPort messagePort;
	}

	testcase TC_NegSem_B010303_permutation_001() runs on GeneralComp {
		timer t := 1.0;
		var MessageType v_testMessage;

		template MessageType mw_matchingTemplate := {
			field1 := {permutation(1, 2, 3), 5},
			field2 := {permutation(1, 2, ?), 5},
			field3 := {permutation(1, 2, 3), *},
			field4 := {permutation((1, 2, 3), 2, 3), 5}
		}

		v_testMessage := {
			field1 := {2, 1, 3, 5},
			field2 := {2, 1, 8, 5},
			field3 := {3, 2, 1, 8, 8},
			field4 := {3, 2, 2, 5}
		};

		t.start;

		messagePort.send(v_testMessage);
		alt {
			[] messagePort.receive(mw_matchingTemplate) {
			  setverdict(pass);
			}
			[] t.timeout {
			  setverdict(fail);
			}
		}
	}
	control {
		execute(TC_NegSem_B010303_permutation_001());
	}
}
