!------------------------------------------------------------------------------!
! Tests for parsing of percent macro with a default value containing a colon (":").
!
! Before the Bug 2934 fix:
!  1. startmacro S:hostport[localhost:6666]      ! works
!  2. startmacro hostport[localhost:6666]        ! fails
!  3. startmacro hostport["localhost:6666"]      ! fails
!  4. procedure hascolon procParam[value:777]    ! works
!
! After fix to Bug 2934:
!  #2 works
!  #3 still fails b/c Args.getValue() does NOT remove the double quotes
!     (they get peeled off later - e.g. HOSTPORT is still correct), but val1 still has quotes
!     such that check for "localhost:6666" EQS val1 fails (line ~30)
!
!   Author : J. Czechowski IV / Jeanette McCall / Neon Ngo
!   Version: $Id: test_macro_parsing_defaults.mm,v 1.9 2015/12/03 19:42:10 ntn Exp $
!------------------------------------------------------------------------------!
startmacro pHostport[localhost:6666] FN:pFileName[localhost:6666] CS:pCaseSensitive[LocalHost:6666] p[:val] L:p5NoDefVal
  switch TESTNAMEPREFIX testNamePrefix GET DEF=""
  switch P5_VAL S:expectedP5SVal GET DEF=""
  switch P5_VAL L:expectedP5LVal GET DEF=0

  set MA this.MA
  if /debug then
    res MA
    res p*
    res exp*
  endif

  set testTextPrefix "^reg.main.name:^{testNamePrefix} % Macro with ':' in default value"

  invoke name MA.name
  set expectedName "%TEST_MACRO_PARSING_DEFAULTS"
  assert/text="^testTextPrefix has proper name" name EQS expectedName

  set expectedVal "LOCALHOST:6666"  ! currently used to check params 1, 2, and 3
  invoke key1 MA.getKey(1)
  invoke val1 MA.getValue(1)
  set expectedKey "PHOSTPORT"
  assert/text="^testTextPrefix has proper key[1]='^expectedKey', actual='^key1'"  key1 EQS expectedKey
  assert/text="^testTextPrefix has proper val[1]='^expectedVal', actual='^val1'"  val1 EQS expectedVal
  assert/text="^testTextPrefix: ^expectedKey results='^expectedVal', actual='^pHostport'" pHostport EQS expectedVal

  invoke key2 MA.getKey(2)
  invoke val2 MA.getValue(2)
  invoke filename MA.getFileName(key2)
  set expectedKey "PFILENAME"
  assert/text="^testTextPrefix has proper key[2]='^expectedKey', actual='^key2'"  key2 EQS expectedKey
  assert/text="^testTextPrefix has proper val[2]='^expectedVal', actual='^val2'"  val2 EQS expectedVal
  assert/text="^testTextPrefix: ^expectedKey results='^filename', actual='^pFileName'" pFileName OEQ filename

  invoke key3 MA.getKey(3)
  invoke val3 MA.getValue(3)
  set expectedKey "PCASESENSITIVE"
! set expectedVal "LocalHost:6666" ! TODO: uncomment this to show issue with CS:foo[MixedCase] NOT keeping case in unquoted default value
  assert/text="^testTextPrefix has proper key[3]='^expectedKey', actual='^key3'"  key3 EQS expectedKey
  assert/text="^testTextPrefix has proper val[3]='^expectedVal', actual='^val3'"  val3 EQS expectedVal /CS
  assert/text="^testTextPrefix: ^expectedKey results='^expectedVal', actual='^pCaseSensitive'" pCaseSensitive EQS expectedVal /CS

  invoke key4 MA.getKey(4)
  invoke val4 MA.getValue(4)
  set expectedKey "P"
  set expectedVal ":VAL"
  assert/text="^testTextPrefix has proper key[4]='^expectedKey', actual='^key4'"  key4 EQS expectedKey
  assert/text="^testTextPrefix has proper val[4]='^expectedVal', actual='^val4'"  val4 EQS expectedVal
  assert/text="^testTextPrefix: ^expectedKey results='^expectedVal', actual='^p'" p    EQS expectedVal

  invoke key5 MA.getKey(5)
  invoke val5 MA.getValue(5)
  set expectedKey "P5NODEFVAL"
  set expectedVal  expectedP5SVal
  assert/text="^testTextPrefix has proper key[5]='^expectedKey', actual='^key5'"  key5 EQS expectedKey
  assert/text="^testTextPrefix has proper val[5]='^expectedVal', actual='^val5'"  val5 EQS expectedVal
  assert/text="^testTextPrefix: ^expectedKey results='^expectedP5LVal', actual='^p5NoDefVal'" p5NoDefVal EQ expectedP5LVal

  res procedure_val 7.7.7
  call hascolon ^procedure_val
endmacro

!****************************************************************************
! Test a procedure with a default value that contains a colon (":")
!****************************************************************************
procedure hascolon procParam[value:777]
  assert/text="^reg.main.name: Procedure where default value has ':' has proper key/val. val='^procParam'" procParam EQS procedure_val
return
