-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to demonstrate lack of expansions in
skipIfBlock
(#1516)
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
forty-two! | ||
it's $36 | ||
args: elif | ||
args: | ||
it's $2A | ||
it's $36 | ||
args: elif | ||
args: |