! Tests for the LOOP and ENDLOOP commands.
!
! @author  Jay Hallam
! @author  J. Czechowski IV
! @version $Id: test_do.mm,v 1.3 2007/07/24 15:35:29 jxc Exp $
!
startmacro
  do count 1 3 1
    result myres_^count 0
  enddo
  assert/text="^reg.main.name: Do with increment of 1" myres_1 EQ 0 AND &
                                       myres_2 EQ 0 AND &
                                       myres_3 EQ 0  
  remove myres*
  do count 1 5 2
    result myres_^count 0
  enddo
  assert/text="^reg.main.name: Do with increment of 2" myres_2 NREXISTS AND &
                                       myres_4 NREXISTS AND &
                                       myres_1 EQ 0 AND &
                                       myres_3 EQ 0 AND &
                                       myres_5 EQ 0  

  set str "|"
  do i 1 10 1
    set str "^{str}^{i}|"
  enddo
  assert/text="^reg.main.name: DO i 1 10 1" str eqs "|1|2|3|4|5|6|7|8|9|10|" and i eq 10

  set str "|"
  do i -1 -10 -1
    set str "^{str}^{i}|"
  enddo
  assert/text="^reg.main.name: DO i -1 -10 -1" str eqs "|-1|-2|-3|-4|-5|-6|-7|-8|-9|-10|" and i eq -10

  set str "|"
  do i 1 9 3
    set str "^{str}^{i}|"
  enddo
  assert/text="^reg.main.name: DO i 1 9 3" str eqs "|1|4|7|" and i eq 7

  set str "|"
  do i -1 -9 -3
    set str "^{str}^{i}|"
  enddo
  assert/text="^reg.main.name: DO i -1 -9 -3" str eqs "|-1|-4|-7|" and i eq -7

  set str "|"
  do i 1 2.1 0.25
    set str "^{str}^{i}|"
  enddo
  assert/text="^reg.main.name: DO i 1 2.1 0.25" str eqs "|1.0|1.25|1.5|1.75|2.0|" and i eq 2.0

  set str "|"
  do i -1 -2.1 -0.25
    set str "^{str}^{i}|"
  enddo
  assert/text="^reg.main.name: DO i -1 -2.1 -0.25" str eqs "|-1.0|-1.25|-1.5|-1.75|-2.0|" and i eq -2.0

  %test_enddo_initialization

endmacro
