! Tests macro where processException throws an exception
! we should not go into an infinite loop
!
! Author:  Neon Ngo
! Since:   NeXtMidas 2.5.0
! Version: $Id: test_macro_bad_5.mm,v 1.3 2011/06/16 17:46:03 hdk Exp $
startmacro
  env get debug old_debug
  debug off trace

  set d:tmp "cause_error1"

  assert/text="Exception in exception handler does not cause infinite loop" TRUE

  if "|TRACE|" subs old_debug.toUpperCase() then
    debug on trace
  endif
endmacro

procedure processException m:emsg
  env get debug old_debug_process_exception
  debug off trace

  !say "^reg.main.name: Unhandled message name: ^emsg.name from fid: ^emsg.fid data: ^emsg.data"
  assert/text="Got expected exception 'cause_error1'" "Unable to convert" SUBS "^emsg.data"

  say "This will print two error messages..."

  set d:tmp2 "cause_sub_error1"
  set d:tmp3 "cause_sub_error2"
  assert/text="^reg.main.name: Handled exceptions thrown in processException" TRUE

  ! this fails in current baseline (2.5.0), when we have nothing better to do, we can look into
  ! fixing this scenario which causes an infinite loop
  !%test_macro_bad_1
  !assert/text="Exception in exception handler continues to next line 2" TRUE

  if "|TRACE|" subs old_debug_process_exception.toUpperCase() then
    debug on trace
  endif
return
