! Tests the UPDATE commands ability to determine a commands abbreviated format
! based on the placement of the "*" symbol in the NAME parameter.
!
! @bug     1497
! @author  Jim Roush
! @version $Id: test_update_abbrev.mm,v 1.4 2014/08/04 13:28:46 ntn Exp $
! @since   NeXtMidas 2.7.0
!******************************************************************************!
startmacro
  set errors {BADABBREV="UPDATE: Illegal command name 'GARB*AGE'. Command names must start with a letter and may only include letters (A-Z) numbers (0-9) and the underscore (_)."}

  ! Points to test option trees
  FILE NAME rootOptDir (^{env.nmroot},nxm,sys,test,nmopts) "" ""
  set oldPath opt.path
  set badupdate true
  set comment "No errors caught."

  option MYTESTOPT1 rootOptDir
  path add MYTESTOPT1
  update GARB*AGE opt=MYTESTOPT1 support=M nargs=2 def1=" " def2="AUX=3"

  update/delete name=GARBAGE opt=MYTESTOPT1
  path set ^oldPath
  OPTION/DELETE MYTESTOPT1

  assert/text="^reg.main.name: ^comment" ^badupdate isTrue
endmacro

!******************************************************************************!
procedure processException m:emsg
  set foundKey ""

  foreach key intable errors
    if "^emsg.data" eqs "nxm.sys.lib.MidasException: ^{errors.^{key}}" then
      set foundKey key
    endif
  endfor

  if foundKey eqs "" then
    set comment "Caught unexpected error: '^emsg.data'"
    set badupdate false
  else
    set comment "Caught: UPDATE '*' abbreviation error!"
    set badupdate false
    rem errors.^{foundKey}
  endif
return
