mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-29 06:17:48 +00:00
23
test/asm/assert.asm
Normal file
23
test/asm/assert.asm
Normal file
@@ -0,0 +1,23 @@
|
||||
SECTION "fixed", ROM0[0]
|
||||
|
||||
FixedBase:
|
||||
assert FixedBase ; This should eval (and fail) at compile time
|
||||
|
||||
ds 0
|
||||
static_assert @ == 0, "@ ain't 0 now? (Hint: it's {@})"
|
||||
|
||||
ds 42
|
||||
assert WARN, @ - FixedBase != 42 ; This should also eval at compile time
|
||||
|
||||
SECTION "floating", ROM0
|
||||
|
||||
FloatingBase:
|
||||
assert FAIL, FloatingBase == 0 ; This shouldn't eval at compile time
|
||||
|
||||
ds 4
|
||||
static_assert FAIL, FloatingBase != 0 ; This is not constant!
|
||||
|
||||
ds 69
|
||||
static_assert FATAL, FixedBase != 0 ; This will fail... ↓
|
||||
; The point of `FATAL` is for stuff that can, say, cause division by 0!
|
||||
static_assert FAIL, 1 / FixedBase, "You dun goofed, son" ; Won't be read
|
||||
10
test/asm/assert.err
Normal file
10
test/asm/assert.err
Normal file
@@ -0,0 +1,10 @@
|
||||
ERROR: assert.asm(4):
|
||||
Assertion failed
|
||||
warning: assert.asm(10): [-Wassert]
|
||||
Assertion failed
|
||||
ERROR: assert.asm(18):
|
||||
Expected constant expression: 'FloatingBase' is not constant at assembly time
|
||||
ERROR: assert.asm(18):
|
||||
Assertion failed
|
||||
ERROR: assert.asm(21):
|
||||
Assertion failed
|
||||
0
test/asm/assert.out
Normal file
0
test/asm/assert.out
Normal file
11
test/link/assert.asm
Normal file
11
test/link/assert.asm
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
SECTION "test", ROM0
|
||||
|
||||
ds 123
|
||||
|
||||
FloatingBase:
|
||||
assert WARN, FloatingBase & 0, "Worry about me, but not too much."
|
||||
assert FAIL, FloatingBase & 0, "Okay, this is getting serious!"
|
||||
assert FATAL, FloatingBase & 0, "It all ends now."
|
||||
assert FAIL, FloatingBase & 0, "Not even time to roll credits!"
|
||||
assert WARN, 0, "Still can finish the film, though!"
|
||||
3
test/link/assert.out
Normal file
3
test/link/assert.out
Normal file
@@ -0,0 +1,3 @@
|
||||
warning: assert.asm(7): Worry about me, but not too much.
|
||||
assert.asm(8): Okay, this is getting serious!
|
||||
error: assert.asm(9): It all ends now.
|
||||
Reference in New Issue
Block a user