!******************************************************************************!
! Additional tests for DATALIST command.
!
!   See BUGs 1593 and 709 for details.
!
!   Author : J. Bauer
!   Version: $Id: test_datalist_packed_and_nibble.mm,v 1.5 2013/11/01 19:10:26 jwb Exp $
!******************************************************************************!
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)
  switch STANDALONE  standalone GET DEF=TRUE  SDEF=TRUE

  call checkDataValues

  if interAct  then
    pipe on
      panel/msgid=MAIN/setup/controls=gc

      if standalone isTrue then
        gcontrol label macro "MACRO"
        gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
        set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      endif

      gcontrol text idtext "INSTRUCTIONS" "The output from the LIST &
                            and LIST2 should have the same values and those &
                            values should match the DATALIST output. Push the &
                            buttons below to see the DATALIST values. " 24 7 /title

      gcontrol button butt "DATALIST TESTS" "SCALAR PACKED,SCALAR PACKED IEEE,SCALAR NIBBLE" /nc=1

      shellgui/id=idshellgui/attach

      list/bg nxm.sys.test.scalar_packed.tmp
      list/bg nxm.sys.test.scalar_packed.tmp{datarep=ieee}
      list/bg nxm.sys.test.scalar_nibble.tmp

      list2/bg nxm.sys.test.scalar_packed.tmp
      list2/bg nxm.sys.test.scalar_packed.tmp{datarep=ieee}
      list2/bg nxm.sys.test.scalar_nibble.tmp

    pipe off
  endif

endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    if msg.data EQS "EXIT" then
      pipe stop
    else
      assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
      pipe stop
    endif
  elseif msg.name eqs "BUTT" then
    if msg.data eqs "SCALAR PACKED" then
      call scalarPacked
    elseif msg.data eqs "SCALAR PACKED IEEE" then
      call scalarPackedIEEE
    elseif msg.data eqs "SCALAR NIBBLE" then
      call scalarNibble
    endif
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
procedure runDatalist
  call scalarPacked
return

!******************************************************************************!
procedure scalarPacked
  say "SCALAR PACKED DATA VALUES:"
  DATALIST/bg nxm.sys.test.scalar_packed.tmp
return

procedure scalarPackedIEEE
  say "SCALAR PACKED DATA VALUES (IEEE):"
  DATALIST/bg nxm.sys.test.scalar_packed.tmp{datarep=ieee}
return

!******************************************************************************!
procedure scalarNibble
  say "SCALAR NIBBLE DATA VALUES:"
  DATALIST/bg nxm.sys.test.scalar_nibble.tmp
return

!******************************************************************************!
procedure checkDataValues
  ! Need to create special variables because there is no IF check for nibble or packed
  res p:expected_pval 1
  res n:expected_nval -1

  assert/text="DATALIST SCALAR PACKED" FILE(nxm.sys.test.scalar_packed.tmp).data(0) eq expected_pval
  assert/text="DATALIST SCALAR PACKED IEEE" FILE(nxm.sys.test.scalar_packed.tmp{size=11}).data(10) eq expected_pval
  assert/text="DATALIST SCALAR NIBBLE" FILE(nxm.sys.test.scalar_nibble.tmp).data(0) eq expected_nval
return
