! This tests the primlab1 macro for the Primitives Lab 1
!
! Author:  Neon Ngo
! Version: $Id: test_primlab3.mm,v 1.1 2007/07/25 19:04:37 ntn Exp $
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  res res1 1.0
  res res2 "a string"

  primlab3 res1 res2
  assert/text="^reg.main.name: res1 is a number and should no longer exist" res1 NREXISTS
  assert/text="^reg.main.name: res2 should exist" res2 REXISTS

  if interAct then
    res inst "Verify the EXPECTED OUTPUT against the ACTUAL OUTPUT."

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      gcontrol text idtext "Instructions" "^inst" 24 4 /title
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

      res res3 3
      res res4 4.0
      res res5 "string 2"

      shellgui/attach
      say ""
      say "EXPECTED OUTPUT:"
      say "INFO: Deleted RES4 (old value = 4.0) [PRIMLAB3]"
      say "WARN: Can not delete result RES5: not a number. [PRIMLAB3]"
      say ""
      say "ACTUAL OUTPUT:"
      say "nM> primlab3 res3"
      say "nM> primlab3 res4 res5 /verbose"
      primlab3 res3
      primlab3 res4 res5 /verbose
    pipe off
  endif
endmacro

procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Tests for PRIMLAB3" msg.data eqss "PASS"
    pipe stop
  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
