From 15919e550ffe4461e3c7d908897db324d48500a6 Mon Sep 17 00:00:00 2001 From: Sylvie <35663410+Rangi42@users.noreply.github.com> Date: Sun, 22 Sep 2024 15:31:12 -0400 Subject: [PATCH] Add test to demonstrate lack of expansions in `skipIfBlock` (#1516) --- test/asm/skip-expansions.asm | 31 +++++++++++++++++++++++++++++++ test/asm/skip-expansions.err | 5 +++++ test/asm/skip-expansions.out | 8 ++++++++ 3 files changed, 44 insertions(+) create mode 100644 test/asm/skip-expansions.asm create mode 100644 test/asm/skip-expansions.err create mode 100644 test/asm/skip-expansions.out diff --git a/test/asm/skip-expansions.asm b/test/asm/skip-expansions.asm new file mode 100644 index 00000000..543526e2 --- /dev/null +++ b/test/asm/skip-expansions.asm @@ -0,0 +1,31 @@ +; skipping ahead to `elif`/`else`/`endc`/`endr`/`endm` disables expansions! + +MACRO mac1 + if _NARG != 2 + println "args: \#" + elif (\2) == 42 + println "forty-two!" + else + println "it's ", (\2) + endc +ENDM + + mac1 elif, 6 * 7 ; this prints "forty-two!" because it takes the `elif` + mac1 elif, 6 * 9 + mac1 elif + mac1 + +MACRO mac2 + if _NARG != 2 + println "args: \#" + \1 (\2) == 42 ; if the `if` is not taken, this is not expanded! + println "forty-two!" + else + println "it's ", (\2) + endc +ENDM + + mac2 elif, 6 * 7 ; this prints "it's $2A" because it skips the `\1` line and takes the `else` + mac2 elif, 6 * 9 + mac2 elif + mac2 diff --git a/test/asm/skip-expansions.err b/test/asm/skip-expansions.err new file mode 100644 index 00000000..5df274e5 --- /dev/null +++ b/test/asm/skip-expansions.err @@ -0,0 +1,5 @@ +error: skip-expansions.asm(31) -> skip-expansions.asm::mac2(21): + Macro argument '\1' not defined +error: skip-expansions.asm(31) -> skip-expansions.asm::mac2(21): + syntax error, unexpected ( +error: Assembly aborted (2 errors)! diff --git a/test/asm/skip-expansions.out b/test/asm/skip-expansions.out new file mode 100644 index 00000000..1e39ac20 --- /dev/null +++ b/test/asm/skip-expansions.out @@ -0,0 +1,8 @@ +forty-two! +it's $36 +args: elif +args: +it's $2A +it's $36 +args: elif +args: