startmacro
!
!  Macro to test the ERASE command
!  @version $Id: test_erase.mm,v 1.9 2009/07/09 19:16:03 jmm Exp $
!
switch INTERACTIVE interAct GET DEF=FALSE  SDEF=TRUE

call test_erase_datafile

call test_erase_textfile

call test_erase_alluppercase

if interAct then
  call test_erase_quiet
endif
endmacro

!**********************************************************************!
procedure test_erase_datafile

if testfile FEXISTS erase testfile
result testfile "temp_dummydatafile"
header/create testfile

if "^testfile" FEXISTS then
  erase testfile
  assert/text="^reg.main.name: erase data file ^testfile" ^testfile NFEXISTS
else
  assert/text="^reg.main.name: unable to perform test, HEADER failure" 1 EQ 2
endif

return

!**********************************************************************!
procedure test_erase_textfile

if testfile FEXISTS erase testfile
result testfile "temp_dummytextfile{FLAGS=FORCEABORT}"
file open/n/t tag "^testfile"
file close tag

if "^testfile" FEXISTS then
  erase testfile
  assert/text="^reg.main.name: erase text file ^testfile" ^testfile NFEXISTS
else
  assert/text="^reg.main.name: unable to perform test, HEADER failure" 1 EQ 2
endif

result testfile "temp_dummytextfile.tmp{FLAGS=FORCEABORT}"
file open/n/t tag "^testfile"
file close tag

if "^testfile" FEXISTS then
  erase/all testfile
  assert/text="^reg.main.name: erase/all text file ^testfile" ^testfile NFEXISTS
else
  assert/text="^reg.main.name: unable to perform ERASE/ALL TEXT FILE test, &
       HEADER failure" 1 EQ 2
endif


return

!**********************************************************************!
procedure test_erase_alluppercase

if testfile FEXISTS erase testfile
result testfile "TEMP_ALLUPPERCASE"
header/create "^testfile"

if "^testfile" FEXISTS then
  erase "^testfile"
  assert/text="^reg.main.name: erase data file ^testfile" "^testfile" NFEXISTS
else
  assert/text="^reg.main.name: unable to perform test, HEADER failure" 1 EQ 2
endif

return

!**********************************************************************!
procedure test_erase_quiet

if testfile FEXISTS erase testfile
result testfile "temp_dummydatafile"
header/create "^testfile"

if "^testfile" FEXISTS then
  erase "^testfile" /quiet /verbose
  ask userResult "Did you see any output <INFO: Erased URL=file:...> from the erase command? [NO] "
  assert/text="^reg.main.name: erase /quiet ^testfile" ^userResult EQS "NO"
else
  assert/text="^reg.main.name: unable to perform test, HEADER failure" 1 EQ 2
endif

return
