!   
!    Test the use of the SET and DEL functions in the SWITCH command
!
!    @Author:  J. Bauer
!    @Version: $Id: test_switch_setdel.mm,v 1.5 2012/06/04 20:10:31 jwb Exp $
!    @BUG 2010  allow command-line over-ride of macro-level switches.
!    
startmacro/testset=100/testdel=50
  
  call test_set
  call test_del
  
endmacro

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Test the SET function
procedure test_set
  res l:testset_val 15
  switch name="TESTSET"  testset_val  func=set   ! Final value should be 15
  switch "TESTSET" testset_val  get       ! Get the value of the switch
  assert/text="^reg.main.name: SET" ^testset_val eq 15
return

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Test the DEL function
procedure test_del
  ! remove switch from all levels but keep value
  switch "TESTDEL" testdel_val func=del         
  switch "TESTDEL" shouldBeDef func=get def=200   ! should be no switch thus it gets the default
  assert/text="^reg.main.name: DEL save value" ^testdel_val eq 55
  assert/text="^reg.main.name: DEL switch gone" shouldBeDef eq 200
  
  ! make new switch with old value
  switch "TESTDEL2"  testdel_val func=set   ! should set to 55 (saved value)
  switch "TESTDEL2" testdel_val2 func=get def=100  ! should get val from above
  
  assert/text="^reg.main.name: DEL reset " ^testdel_val2 eq 55
return