/***************************************************
 ** @author   STF 409
 ** @version  0.0.1
 ** @purpose  1:B.1.5.5, Ensure that the IUT correctly handles character pattern compatibility rules of template matching
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

module Sem_B010505_pattern_compatibility_002 {

    modulepar {
     universal charstring MOD_REF:="modulepar reference";
    }

    type record MessageType {
     charstring  		field1,
     charstring		field2,
     charstring		field3,
     charstring  		field4,
     charstring		field5,
     charstring		field6,
     charstring		field7
    }

    type port loopbackPort message {
      inout MessageType
    }

    const universal charstring c_Ref:="constant reference";


type component GeneralComp {
      port loopbackPort messagePort
}

testcase TC_Sem_B010505_pattern_compatibility_002(universal charstring p_Ref) runs on GeneralComp {

    var MessageType v_testMessage;
    var universal charstring v_Ref:="variable reference";
    template universal charstring m_Ref:= pattern "{c_Ref}";
    template universal charstring m_RefExp_p1 := pattern "{m_";
    template universal charstring m_RefExp_p2 := pattern "Ref}!";

 template MessageType mw_matchingTemplate:=
 {
  field1 := pattern "{v_Ref}",
  field2 := pattern "{c_Ref}",
  field3 := pattern "{MOD_REF}",
  field4 := pattern "{p_Ref}",
  field5 := pattern "{m_Ref}",
  field6 := pattern "{m_"&"Ref}!",
  field7 := pattern "{m_RefExp_p1}{m_RefExp_p2}"
 }

 v_testMessage:=  {
  field1 := "variable reference",
  field2 := "constant reference",
  field3 := "modulepar reference",
  field4 := "parameter reference",
  field5 := "constant reference",
  field6 := "constant reference!",
  field7 := "{m_Ref}!"
 }

 messagePort.send(v_testMessage);

    alt {
     [] messagePort.receive(mw_matchingTemplate) {
        setverdict(pass);
     }
     [] messagePort.receive {
        setverdict(fail);
     }
    }
}

control{
    execute(TC_Sem_B010505_pattern_compatibility_002("parameter reference"));
}

}
