! This macro will test of the RUN command. Note that this relies on the
! test_run_assist.mm macro for the testing of RUN/PARENT
!
! @author  J. Czechowski IV
! @version $Id: test_run.mm,v 1.4 2004/07/14 18:52:37 jxc Exp $

startmacro
  call test_run_default
  call test_run_with_flags
endmacro


!******************************************************************************!
procedure test_run_default
  !
  !  Test the "RUN ..." syntax (no flags)
  !
  res n 0
  run "res n 7"
  run assert/text="RUN: (TEST 1 OF 2)" n EQ 7

  run res x 42
  run assert/text="RUN: (TEST 2 OF 2)" x EQ 42

return

!******************************************************************************!
procedure test_run_with_flags
  !
  !  Test the "RUN/PARENT" syntax (no flags)
  !

  ! Set FOO and BAR both locally and globally
  run/GLOBAL res TEST_RUN_BAR 100
  run/GLOBAL res TEST_RUN_FOO 100
  run        res TEST_RUN_BAR   0
  run        res TEST_RUN_FOO   0

  res TR_FOO 2000
  res TR_BAR 2000

  ! Run the macro that does the following to show /PARENT modification of
  ! FOO and /GLOBAL modification of bar:
  !
  !    startmacro
  !      RES TEST_RUN_FOO -100
  !      RES TEST_RUN_BAR -200
  !
  !      RUN/PARENT "CALC TEST_RUN_FOO TEST_RUN_FOO 1 +"
  !      RUN/GLOBAL "CALC TEST_RUN_BAR TEST_RUN_BAR 2 +"
  !
  !      run/parent res TR_FOO ^TEST_RUN_FOO
  !      run/parent res TR_BAR ^TEST_RUN_BAR
  !    endmacro
  !
  %test_run_assist

  ! Test FOO to see that it's local version is changed and it's global version
  ! is NOT changed.

  run        assert/text="RUN/PARENT: (TEST 1 OF 2)" TR_FOO EQ -100
  run        assert/text="RUN/PARENT: (TEST 2 OF 2)" TEST_RUN_FOO EQ 1
  run        rem TEST_RUN_FOO
  
  run/GLOBAL assert/text="RUN/PARENT: (TEST 3 OF 2)" TEST_RUN_FOO EQ 100
  run/GLOBAL rem TEST_RUN_FOO


  ! Test BAR to see that it's local version is NOT changed and it's global
  ! version is changed.

  run        assert/text="RUN/GLOBAL: (TEST 1 OF 2)" TR_BAR EQ -200
  run        assert/text="RUN/GLOBAL: (TEST 2 OF 2)" TEST_RUN_BAR EQ 0
  run        rem TEST_RUN_BAR
  
  run/GLOBAL assert/text="RUN/GLOBAL: (TEST 3 OF 2)" TEST_RUN_BAR EQ 102
  run/GLOBAL rem TEST_RUN_BAR

return


