!******************************************************************************!
! Test case to SETSEED command
!
! Arguments: None
!
! @since    NeXtMidas 3.1.1
! @author:  Neon Ngo
! @version: $Id: test_setseed.mm,v 1.1 2012/03/14 22:04:46 ntn Exp $
!******************************************************************************!
startmacro
  setseed/gen
  invoke seed nxm.sys.libm.Random.getSeed()  ! save value for next test
  calc x1 random
  calc x2 random
  assert/text="SETSEED: RANDOM within range (0-1) for x1" x1 > 0 AND x1 < 1
  assert/text="SETSEED: RANDOM within range (0-1) for x2" x2 > 0 AND x2 < 1

  setseed seed
  calc y1 random
  calc y2 random
  assert/text="SETSEED: RANDOM x1 same as y1 after using same seed value" x1 == y1
  assert/text="SETSEED: RANDOM x1 same as y1 after using same seed value" x2 == y2
  assert/text="SETSEED: RANDOM within range (0-1) for y1" y1 > 0 AND y1 < 1
  assert/text="SETSEED: RANDOM within range (0-1) for y2" y2 > 0 AND y2 < 1

endmacro

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return
