!******************************************************************************!
! Test parser returning warning for ambiguous matches
!
! @bug      2680 Parser: Ambiguous matches do not produce a warning or notice to user
! @author:  J Bauer
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  if interAct then
    set instructions "You should see a label 'LABEL UNO' that is closed and a button with the text 'OPEN'. \n\n&
                      Click the button 'OPEN' to open 'LABEL UNO'.\n\n&
                      You should then see a CHOICE and a PROMPT under LABEL UNO\n\n&
                      There should be a warning in the terminal 'Ambiguous items match...' "

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      !gcontrol label macro "Test MACRO"
      gcontrol menu  main "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft

      gcontrol text  idtext "Instructions" instructions 24 12 /title

      info "There should be a warning below stating 'Ambiguous items match 'ALWAYS''"
      gcontrol label myLabel "LABEL UNO" Always Open  ! Deliberate syntax error
        gcontrol choice myChoice "Some Choices:" "A,B,C,D"
        gcontrol prompt myPrompt "A Prompt!" "Prompt Text!"

      gcontrol label opener "Click my button!"
        gcontrol button myButt "" "OPEN" ""

    pipe off

  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop

  elseif msg.name eqs "MYBUTT" then
    set gc.mylabel.value "OPEN"

  else
    !say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return
