Avoid nonessential EQUS expansion in tests

This commit is contained in:
Rangi42
2025-09-06 13:30:01 -04:00
parent 94ed28acf8
commit c8a088f281
24 changed files with 68 additions and 57 deletions

View File

@@ -12,7 +12,9 @@ MACRO with_each
endr endr
ENDM ENDM
DEF with_each_stat EQUS "with_each HP, ATK, DEF," MACRO with_each_stat
with_each HP, ATK, DEF, \1
ENDM
with_each_stat """ with_each_stat """
println STRFMT("Average ? is %d", (SLIME_? + MIMIC_?) / 2) println STRFMT("Average ? is %d", (SLIME_? + MIMIC_?) / 2)

View File

@@ -1,3 +1,3 @@
def DEFINE equs "MACRO mac\nPRINTLN \"Hello :D\"\nENDM" def DEFINE equs "MACRO mac\nPRINTLN \"Hello :D\"\nENDM"
DEFINE {DEFINE}
mac mac

View File

@@ -1,3 +1,3 @@
def X equs "redef X equs \"\\\"Success!\\\\n\\\"\"" def X equs "redef X equs \"\\\"Success!\\\\n\\\"\""
X {X}
print X print {X}

View File

@@ -1,4 +1,4 @@
def ACT equs "WARN \"First\"\nWARN \"Second\"" def ACT equs "WARN \"First\"\nWARN \"Second\""
ACT {ACT}
WARN "Third" WARN "Third"

View File

@@ -1,2 +1,2 @@
def BYE equs "PURGE BYE\nWARN \"Crash?\"\n \n" def BYE equs "PURGE BYE\nWARN \"Crash?\"\n \n"
BYE {BYE}

View File

@@ -1,23 +1,23 @@
def string_start equs "println \"hello" def string_start equs "println \"hello"
string_start world" {string_start} world"
def triple_string_start equs "println \"\"\"multi" def triple_string_start equs "println \"\"\"multi"
triple_string_start;ple {triple_string_start};ple
line line
strings""" strings"""
def cond_start equs "if 0\nprintln \"false\"\nelif" def cond_start equs "if 0\nprintln \"false\"\nelif"
cond_start 1 {cond_start} 1
println "true" println "true"
else else
println "nan" println "nan"
endc endc
def loop_start equs "rept 3\nprintln" def loop_start equs "rept 3\nprintln"
loop_start "lol" {loop_start} "lol"
endr endr
def macro_start equs "macro foo\nprintln" def macro_start equs "macro foo\nprintln"
macro_start \1 {macro_start} \1
endm endm
foo 42 foo 42

View File

@@ -9,7 +9,7 @@ def INDEX = 1{ZERO_STR}{{FMT}:ZERO_NUM}
; Defines ITEM_100 as "\"hundredth\"" ; Defines ITEM_100 as "\"hundredth\""
def {NAME}_{d:INDEX} equs "\"hundredth\"" def {NAME}_{d:INDEX} equs "\"hundredth\""
; Prints "ITEM_100 is hundredth" ; Prints "ITEM_100 is hundredth"
PRINTLN STRCAT("{NAME}_{d:INDEX}", " is ", {NAME}_{d:INDEX}) PRINTLN STRCAT("{NAME}_{d:INDEX}", " is ", {{NAME}_{d:INDEX}})
; Purges ITEM_100 ; Purges ITEM_100
PURGE {NAME}_{d:INDEX} PURGE {NAME}_{d:INDEX}
ASSERT !DEF({NAME}_{d:INDEX}) ASSERT !DEF({NAME}_{d:INDEX})

View File

@@ -22,12 +22,12 @@ ENDM
MACRO test_char MACRO test_char
DEF VAR_DEF equs "DEF sizeof_\1something = 0" DEF VAR_DEF equs "DEF sizeof_\1something = 0"
VAR_DEF {VAR_DEF}
DEF sizeof_\1something = 1 DEF sizeof_\1something = 1
PURGE VAR_DEF PURGE VAR_DEF
DEF VAR_PRINT equs "println \"sizeof_\1something equals {sizeof_\1something}\"" DEF VAR_PRINT equs "println \"sizeof_\1something equals {sizeof_\1something}\""
VAR_PRINT {VAR_PRINT}
PURGE VAR_PRINT PURGE VAR_PRINT
ENDM ENDM

View File

@@ -14,20 +14,29 @@ ENDR
; string of 127 zeros separated by plus signs ; string of 127 zeros separated by plus signs
DEF X EQUS "{X7E}" DEF X EQUS "{X7E}"
db x+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+\ db x+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+\ {X}+{X}+{X}+{X}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}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+{X}+\
{X}+{X}+{X}+{X}+{X}+{X}+{X}
x: db 0 x: db 0
; this tests long RPN expressions being used as the RHS, as this once triggered ; this tests long RPN expressions being used as the RHS, as this once triggered
; a realloc bug ; a realloc bug
db 1+(x+X) db 1+(x+{X})
; likewise, a long symbol could result in an insufficient *initial* allocation ; likewise, a long symbol could result in an insufficient *initial* allocation
db A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000+0+0 db A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000+0+0

View File

@@ -1,6 +1,6 @@
MACRO outer_ok MACRO outer_ok
def definition equs "MACRO inner_ok\nPRINTLN \"Hello!\"\nENDM" def definition equs "MACRO inner_ok\nPRINTLN \"Hello!\"\nENDM"
definition {definition}
PURGE definition PURGE definition
ENDM ENDM
@@ -10,7 +10,7 @@ ENDM
MACRO outer_arg MACRO outer_arg
def definition equs "MACRO inner_arg\nPRINTLN \"outer: \1\\ninner: \\1\"\nENDM" def definition equs "MACRO inner_arg\nPRINTLN \"outer: \1\\ninner: \\1\"\nENDM"
definition {definition}
PURGE definition PURGE definition
ENDM ENDM

View File

@@ -7,7 +7,7 @@ MACRO outer
PURGE inner PURGE inner
ENDC ENDC
DEF s EQUS "\nMACRO inner\nREPT 2\nREPT 2\nWARN \"round \{d:it\}\"\nDEF it += 1\nENDR\nENDR\nENDM" DEF s EQUS "\nMACRO inner\nREPT 2\nREPT 2\nWARN \"round \{d:it\}\"\nDEF it += 1\nENDR\nENDR\nENDM"
s {s}
PURGE s PURGE s
ENDC ENDC
inner inner

View File

@@ -1,7 +1,7 @@
macro test macro test
; Test the rpn system, as well as the linker... ; Test the rpn system, as well as the linker...
DEF expr EQUS STRRPL(STRRPL("\1 + zero)", "<< ", "<< ("), ">> ", ">> (") DEF expr EQUS STRRPL(STRRPL("\1 + zero)", "<< ", "<< ("), ">> ", ">> (")
dl expr dl {expr}
PURGE expr PURGE expr
; ...as well as the constexpr system ; ...as well as the constexpr system

View File

@@ -1,5 +1,5 @@
DEF VAL EQUS STRFMT("Hello %s! I am %d years old today!", "world", $f) DEF VAL EQUS STRFMT("Hello %s! I am %d years old today!", "world", $f)
PRINTLN "{VAL}" PRINTLN #VAL
DEF N = -42 DEF N = -42
PRINTLN STRFMT("signed %010d == unsigned %010u", N, N) PRINTLN STRFMT("signed %010d == unsigned %010u", N, N)
@@ -10,10 +10,10 @@ PRINTLN STRFMT("\tdb %#03{s:FMT} %% 26\t; %#03{FMT}", N, N % 26)
PRINTLN STRFMT("%d = %#x = %#b = %#o != %f", 42, 42, 42, 42, 42.0) PRINTLN STRFMT("%d = %#x = %#b = %#o != %f", 42, 42, 42, 42, 42.0)
DEF TEMPLATE EQUS "\"%s are %s\\n\"" DEF TEMPLATE EQUS "%s are %s\n"
PRINT STRFMT(TEMPLATE, "roses", "red") PRINT STRFMT(#TEMPLATE, "roses", "red")
PRINT STRFMT(TEMPLATE, "violets", "blue") PRINT STRFMT(#TEMPLATE, "violets", "blue")
PRINT STRFMT(TEMPLATE, "void", 0, "extra") PRINT STRFMT(#TEMPLATE, "void", 0, "extra")
PRINTLN STRCAT(STRFMT(STRFMT("%%%s.%d%s", "", 9, "f"), 3.14159), \ PRINTLN STRCAT(STRFMT(STRFMT("%%%s.%d%s", "", 9, "f"), 3.14159), \
STRFMT(" ~ %s", STRFMT("%s%x", "thr", 238))) STRFMT(" ~ %s", STRFMT("%s%x", "thr", 238)))

View File

@@ -4,7 +4,7 @@ MACRO m1
PRINTLN "Within nested MACRO: \\@" PRINTLN "Within nested MACRO: \\@"
\n ENDM \n ENDM
mm""" mm"""
nested {nested}
PURGE nested, mm PURGE nested, mm
PRINTLN "Within MACRO: \@" PRINTLN "Within MACRO: \@"
ENDM ENDM
@@ -22,7 +22,7 @@ MACRO m2
PRINTLN "Within nested MACRO: \\@" PRINTLN "Within nested MACRO: \\@"
\n ENDM \n ENDM
mm""" mm"""
nested {nested}
PURGE nested, mm PURGE nested, mm
PRINTLN "Within MACRO: \@" PRINTLN "Within MACRO: \@"
ENDM ENDM

View File

@@ -1,15 +1,15 @@
DEF warn_unique EQUS "WARN \"\\@!\"" DEF warn_unique EQUS "WARN \"\\@!\""
macro m macro m
warn_unique {warn_unique}
REPT 2 REPT 2
warn_unique {warn_unique}
ENDR ENDR
warn_unique {warn_unique}
endm endm
warn_unique {warn_unique}
m m
warn_unique {warn_unique}
m m
warn_unique {warn_unique}

View File

@@ -1,14 +1,14 @@
def fzero equs "startof(\"test\")" def fzero equs "startof(\"test\")"
section "test", rom0 section "test", rom0
ld a, $8000_0000 / (fzero - 1) ld a, $8000_0000 / ({fzero} - 1)
ld a, $8000_0000 / (fzero - 2) ld a, $8000_0000 / ({fzero} - 2)
ld a, 1 << (fzero - 1) ld a, 1 << ({fzero} - 1)
ld a, 1 << (fzero + 32) ld a, 1 << ({fzero} + 32)
ld a, (fzero - 1) >> 1 ld a, ({fzero} - 1) >> 1
ld a, 1 >> (fzero - 1) ld a, 1 >> ({fzero} - 1)
ld a, 1 >> (fzero + 32) ld a, 1 >> ({fzero} + 32)
ld a, 1 >>> (fzero - 1) ld a, 1 >>> ({fzero} - 1)
ld a, 1 >>> (fzero + 32) ld a, 1 >>> ({fzero} + 32)
; We rely on this landing at address $0000, which isn't *guaranteed*... ; We rely on this landing at address $0000, which isn't *guaranteed*...
assert startof("test") == 0 assert startof("test") == 0

View File

@@ -4,7 +4,7 @@ ELSE
def ATTRS equs "[$CAFE]" def ATTRS equs "[$CAFE]"
ENDC ENDC
SECTION UNION "conflicting alignment", WRAM0 ATTRS SECTION UNION "conflicting alignment", WRAM0 {ATTRS}
db db
PURGE ATTRS PURGE ATTRS

View File

@@ -4,7 +4,7 @@ ELSE
def ATTRS equs ",ALIGN[4,14]" def ATTRS equs ",ALIGN[4,14]"
ENDC ENDC
SECTION UNION "conflicting alignment", WRAM0 ATTRS SECTION UNION "conflicting alignment", WRAM0 {ATTRS}
db db
PURGE ATTRS PURGE ATTRS

View File

@@ -4,7 +4,7 @@ ELSE
def TYPE equs "WRAM0" def TYPE equs "WRAM0"
ENDC ENDC
SECTION UNION "conflicting types", TYPE SECTION UNION "conflicting types", {TYPE}
db db
PURGE TYPE PURGE TYPE

View File

@@ -2,7 +2,7 @@ IF !DEF(SECOND)
def SECOND equs "4" def SECOND equs "4"
ENDC ENDC
SECTION UNION "conflicting banks", WRAMX, BANK[SECOND] SECTION UNION "conflicting banks", WRAMX, BANK[{SECOND}]
db db
PURGE SECOND PURGE SECOND

View File

@@ -5,6 +5,6 @@ ELSE
ENDC ENDC
SECTION UNION "overlaid data", ROM0 SECTION UNION "overlaid data", ROM0
DATA {DATA}
PURGE DATA PURGE DATA

View File

@@ -4,7 +4,7 @@ ELSE
def ATTRS equs ",ALIGN[3,6]" def ATTRS equs ",ALIGN[3,6]"
ENDC ENDC
SECTION UNION "conflicting alignment", WRAM0 ATTRS SECTION UNION "conflicting alignment", WRAM0 {ATTRS}
db db
PURGE ATTRS PURGE ATTRS

View File

@@ -5,6 +5,6 @@ ELSE
ENDC ENDC
SECTION UNION "different syntaxes", ROM0 SECTION UNION "different syntaxes", ROM0
INSTR {INSTR}
PURGE INSTR PURGE INSTR

View File

@@ -5,6 +5,6 @@ ELSE
ENDC ENDC
SECTION UNION "mutually-overlaid data", ROM0 SECTION UNION "mutually-overlaid data", ROM0
DATA {DATA}
PURGE DATA PURGE DATA