/******************************************************************************
 * Copyright (c) 2000-2025 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Szabo, Bence Janos
 *
 ******************************************************************************/
module TempMandatory_SE { //^In TTCN-3 module//

/*This test checks that an error is produced if * is used for a mandatory field*/

type component Empty_CT {};

type record Rec1 { integer f }
type union Uni { integer u }

testcase tc_check_mandatory() runs on Empty_CT {  //^In testcase definition `tc_check_mandatory'://

   var template Uni vl_Uni;
   var template Rec1 vl_Rec1;

  vl_Uni:={u:=*}; //^In variable assignment:// \
  //^In template for union field `u':// \
  //^error: Using \`\*\' for mandatory field//
  if (not isbound(vl_Uni)) {setverdict(fail)}
  if (isvalue(vl_Uni)) {setverdict(fail)}
  if (not ispresent(vl_Uni)) {setverdict(fail)}

  if (not isbound(vl_Uni.u)) {setverdict(fail)}
  if (isvalue(vl_Uni.u)) {setverdict(fail)}
  if (ispresent(vl_Uni.u)) {setverdict(fail)}


  vl_Rec1:={f:=*}; //^In variable assignment:// \
  //^In template for record field `f':// \
  //^error: Using \`\*\' for mandatory field//
  if (not isbound(vl_Rec1)) {setverdict(fail)}
  if (isvalue(vl_Rec1)) {setverdict(fail)}
  if (not ispresent(vl_Rec1)) {setverdict(fail)}

  if (not isbound(vl_Rec1.f)) {setverdict(fail)}
  if (isvalue(vl_Rec1.f)) {setverdict(fail)}
  if (ispresent(vl_Rec1.f)) {setverdict(fail)}
  
  setverdict(pass);
}

control {
  execute(tc_check_mandatory());
}

}
