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
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 """
println STRFMT("Average ? is %d", (SLIME_? + MIMIC_?) / 2)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ def INDEX = 1{ZERO_STR}{{FMT}:ZERO_NUM}
; Defines ITEM_100 as "\"hundredth\""
def {NAME}_{d:INDEX} equs "\"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
PURGE {NAME}_{d:INDEX}
ASSERT !DEF({NAME}_{d:INDEX})

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
macro test
; Test the rpn system, as well as the linker...
DEF expr EQUS STRRPL(STRRPL("\1 + zero)", "<< ", "<< ("), ">> ", ">> (")
dl expr
dl {expr}
PURGE expr
; ...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)
PRINTLN "{VAL}"
PRINTLN #VAL
DEF N = -42
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)
DEF TEMPLATE EQUS "\"%s are %s\\n\""
PRINT STRFMT(TEMPLATE, "roses", "red")
PRINT STRFMT(TEMPLATE, "violets", "blue")
PRINT STRFMT(TEMPLATE, "void", 0, "extra")
DEF TEMPLATE EQUS "%s are %s\n"
PRINT STRFMT(#TEMPLATE, "roses", "red")
PRINT STRFMT(#TEMPLATE, "violets", "blue")
PRINT STRFMT(#TEMPLATE, "void", 0, "extra")
PRINTLN STRCAT(STRFMT(STRFMT("%%%s.%d%s", "", 9, "f"), 3.14159), \
STRFMT(" ~ %s", STRFMT("%s%x", "thr", 238)))

View File

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

View File

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