mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Merge pull request #490 from ISSOtm/const
Implement `ISCONST`, reporting compile-time constness
This commit is contained in:
29
test/asm/isconst.asm
Normal file
29
test/asm/isconst.asm
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
TEST_NUM = 0
|
||||
|
||||
test_expr: MACRO
|
||||
TEST_NUM = TEST_NUM + 1
|
||||
|
||||
IS_CONST = ISCONST(\1)
|
||||
PRINTT "Test #{d:TEST_NUM}: ISCONST reports {IS_CONST}\n"
|
||||
IF (\1) || 1 ; Only test if the expression can be evaluated
|
||||
WARN "Test #{d:TEST_NUM}: Compile-time constant"
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
test_expr 1
|
||||
test_expr UnknownLabel
|
||||
|
||||
SECTION "fixed", WRAM0[$CAFE]
|
||||
|
||||
FixedLabel:
|
||||
ds 42
|
||||
test_expr FixedLabel
|
||||
test_expr @ - FixedLabel
|
||||
|
||||
SECTION "floating", WRAMX
|
||||
|
||||
FloatingLabel:
|
||||
ds 69
|
||||
test_expr FloatingLabel
|
||||
test_expr @ - FloatingLabel
|
||||
13
test/asm/isconst.err
Normal file
13
test/asm/isconst.err
Normal file
@@ -0,0 +1,13 @@
|
||||
warning: isconst.asm(14) -> isconst.asm::test_expr(10): [-Wuser]
|
||||
Test #1: Compile-time constant
|
||||
ERROR: isconst.asm(15) -> isconst.asm::test_expr(9):
|
||||
Expected constant expression: 'UnknownLabel' is not constant at assembly time
|
||||
warning: isconst.asm(21) -> isconst.asm::test_expr(10): [-Wuser]
|
||||
Test #3: Compile-time constant
|
||||
warning: isconst.asm(22) -> isconst.asm::test_expr(10): [-Wuser]
|
||||
Test #4: Compile-time constant
|
||||
ERROR: isconst.asm(28) -> isconst.asm::test_expr(9):
|
||||
Expected constant expression: 'FloatingLabel' is not constant at assembly time
|
||||
warning: isconst.asm(29) -> isconst.asm::test_expr(10): [-Wuser]
|
||||
Test #6: Compile-time constant
|
||||
error: Assembly aborted (2 errors)!
|
||||
6
test/asm/isconst.out
Normal file
6
test/asm/isconst.out
Normal file
@@ -0,0 +1,6 @@
|
||||
Test #1: ISCONST reports $1
|
||||
Test #2: ISCONST reports $0
|
||||
Test #3: ISCONST reports $1
|
||||
Test #4: ISCONST reports $1
|
||||
Test #5: ISCONST reports $0
|
||||
Test #6: ISCONST reports $1
|
||||
Reference in New Issue
Block a user