!******************************************************************************!
! Test for inconsistent handling of whitespace within a table
! This test will check for originial functionality.
! To call this macro, need to set default flags +DisableConsistentHandlingOfWhiteSpace
!
! @bug      NXM-3143 Inconsistent handling of whitespace within a table
! @since    NextMidas 3.8.1
! @author:  Jeanette McCall
!
! CAUTION: editing this file in Eclipse may result in loss of TABS for tab test
!
!******************************************************************************!
startmacro  
  ! Table without whitespace for expected
  set tblexp {KEY1="FIRST VALUE",KEY2="SECOND",KEY3=THIRD,KEY4=4}

  ! Extra SPACEs ignored
  set tbl1ws { KEY1 = "FIRST VALUE", KEY2 =  "SECOND", KEY3 = THIRD, KEY4 = 4}
  table tbl1ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with SPACEs after equals not ignored" tables_are_equal isFalse
  
  ! Wrap ignored
  set tbl2ws { KEY1 = &
  "FIRST VALUE", KEY2 =  "SECOND", KEY3 = THIRD, KEY4 = 4}
  table tbl2ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with newline after equals not ignored" tables_are_equal isFalse

  ! Tabs ignored - BE CAREFUL EDITING in Eclipse - may have setting that turns tabs into spaces - these are tabs!
  set tbl3ws {	KEY1	=	"FIRST VALUE",	KEY2 =	"SECOND",	KEY3	=	THIRD,	KEY4	=	4}
  table tbl3ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with TABs after equals not ignored" tables_are_equal isFalse

  ! Extra SPACEs before , ignored
  set tbl4ws { KEY1 = "FIRST VALUE" , KEY2 =  "SECOND", KEY3 = THIRD , KEY4 = 4}
  table tbl4ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with SPACEs before comma not ignored" tables_are_equal isFalse

  table tbl5ws create { KEY1 = "FIRST VALUE" , KEY2 =		"SECOND", KEY3 = THIRD , KEY4 = 4}
  table tbl5ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with TABs after equals not ignored" tables_are_equal isFalse

  table tbl6ws create { KEY1	= "FIRST VALUE",	KEY2 =  "SECOND", KEY3  = THIRD,  KEY4  = 4}
  table tbl6ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with SPACEs after equals not ignored" tables_are_equal isFalse

  table tbl7ws create { KEY1 = "FIRST VALUE", KEY2 =  "SECOND", KEY3 = THIRD, KEY4 = 4}
  table tbl7ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with TABs after equals not ignored" tables_are_equal isFalse

  table tbl8ws create { KEY1 = &
  "FIRST VALUE", KEY2 =  &
  "SECOND", KEY3 = THIRD, KEY4 = &
  4}
  table tbl8ws equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table with newline after equals not ignored" tables_are_equal isFalse
  assert/text="^reg.main.name: The value wrong with spaces between end of value and the comma" tables_are_equal isFalse


  !This is a test to confirm that the values are equal. In the macro, the comma between the to key value pairs is removed when there is a space before the comma.
  !In the junit test, it is not removed so the value is different.
  table tbl4ws GETKEY "KEY1" badVal
  res expetedBadVal " \"FIRST VALUE\"  KEY2 =  \"SECOND\""
  assert/text="^reg.main.name: Table with SPACE before comma has bad value" badVal eqs expetedBadVal

  !Test the same tables loaded from a file. Using the Load method of table.
  TABLE tblFile LOAD "nxm.sys.test.test_table_whitespace.tbl"
  table tblFile.tbl1wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with SPACEs after equals not ignored" tables_are_equal isFalse
  table tblFile.tbl2wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with newline after equals not ignored" tables_are_equal isFalse
  table tblFile.tbl3wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with TABs after equals not ignored" tables_are_equal isFalse
  table tblFile.tbl4wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with SPACEs before comma not ignored" tables_are_equal isFalse

  !Test the same tables loaded from a file. Using the Create method of table.
  TABLE tblFile2 create "nxm.sys.test.test_table_whitespace.tbl"
  table tblFile2.tbl1wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with SPACEs after equals not ignored" tables_are_equal isFalse
  table tblFile2.tbl2wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with newline after equals not ignored" tables_are_equal isFalse
  table tblFile2.tbl3wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with TABs after equals not ignored" tables_are_equal isFalse
  table tblFile2.tbl4wsfile equals tblexp tables_are_equal
  assert/text="^reg.main.name: Table (file) with SPACEs before comma not ignored" tables_are_equal isFalse
  
endmacro
