Verify uneven list sizes with list_start, li, and assert_list_length macros

This was discussed in #815
This commit is contained in:
Rangi
2021-03-22 17:15:21 -04:00
parent dbe2360ecd
commit 94057c7726
10 changed files with 663 additions and 618 deletions

View File

@@ -19,6 +19,31 @@ x = \1
"{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
ENDM
list_start: MACRO
list_index = 0
if DEF(CURRENT_LIST_START)
PURGE CURRENT_LIST_START
endc
if _NARG == 1
CURRENT_LIST_START EQUS "\1"
else
CURRENT_LIST_START EQUS "._list_start\@"
CURRENT_LIST_START:
endc
ENDM
li: MACRO
assert !STRIN(\1, "@"), STRCAT("String terminator \"@\" in list entry: ", \1)
db \1, "@"
list_index = list_index + 1
ENDM
assert_list_length: MACRO
x = \1
assert x == list_index, \
"{CURRENT_LIST_START}: expected {d:x} entries, got {d:list_index}"
ENDM
def_grass_wildmons: MACRO
;\1: map id
if DEF(CURRENT_GRASS_WILDMONS_MAP)