Add more test coverage

This commit is contained in:
Rangi42
2025-09-04 01:29:50 -04:00
parent 4f702a4be8
commit 5b67dc94b6
13 changed files with 34 additions and 5 deletions

View File

@@ -47,7 +47,9 @@ void act_Elif(int32_t condition) {
if (lexer_ReachedELSEBlock()) {
fatal("Found `ELIF` after an `ELSE` block");
}
lexer_SetMode(LEXER_SKIP_TO_ENDC);
// This should be redundant, as the lexer will have skipped to `ENDC` since
// an `ELIF` after a taken `IF` needs to not evaluate its condition.
lexer_SetMode(LEXER_SKIP_TO_ENDC); // LCOV_EXCL_LINE
} else if (condition) {
lexer_RunIFBlock();
} else {
@@ -61,7 +63,8 @@ void act_Else() {
}
if (lexer_RanIFBlock()) {
if (lexer_ReachedELSEBlock()) {
fatal("Found `ELSE` after an `ELSE` block");
// This should be redundant, as the lexer handles this error first.
fatal("Found `ELSE` after an `ELSE` block"); // LCOV_EXCL_LINE
}
lexer_SetMode(LEXER_SKIP_TO_ENDC);
} else {

View File

@@ -406,13 +406,16 @@ static Section *getSection(
bank = sectionTypeInfo[type].firstBank;
}
// This should be redundant, as the parser guarantees that `AlignmentSpec` will be valid.
if (alignOffset >= alignSize) {
// LCOV_EXCL_START
error(
"Alignment offset (%" PRIu16 ") must be smaller than alignment size (%" PRIu32 ")",
alignOffset,
alignSize
);
alignOffset = 0;
// LCOV_EXCL_STOP
}
if (org != UINT32_MAX) {

View File

@@ -0,0 +1,2 @@
section fragment "aligned", wram0[$c002], align[1]
section fragment "aligned", wram0, align[2]

View File

@@ -0,0 +1,4 @@
error: Section already declared as fixed at incompatible address $c002
at fragment-align-mismatch.asm(2)
FATAL: Cannot create section "aligned" (1 error)
at fragment-align-mismatch.asm(2)

View File

@@ -0,0 +1 @@
dw [[ db 42 ]]

View File

@@ -0,0 +1,2 @@
FATAL: Cannot output fragment literals outside of a `SECTION`
at fragment-literal-outside-section.asm(1)

View File

@@ -25,6 +25,7 @@ println 0b101010_
println 0o123456_
println 0xabcdef_
println `01230123_
println 123.456_
; bad ('_' next to '.')
println 1_.618

View File

@@ -22,8 +22,10 @@ error: Invalid integer constant, trailing '_'
at invalid-underscore.asm(26)
error: Invalid graphics constant, trailing '_'
at invalid-underscore.asm(27)
error: Invalid fixed-point constant, trailing '_'
at invalid-underscore.asm(28)
error: Invalid integer constant, trailing '_'
at invalid-underscore.asm(30)
error: Invalid integer constant, '_' after another '_'
at invalid-underscore.asm(31)
Assembly aborted with 14 errors!
error: Invalid integer constant, '_' after another '_'
at invalid-underscore.asm(32)
Assembly aborted with 15 errors!

View File

@@ -20,5 +20,6 @@ $2A
$A72E
$ABCDEF
$3355
$7B74BC
$19E35
$2B7CF

View File

@@ -0,0 +1 @@
section "test", rom0, align[2, 99]

View File

@@ -0,0 +1,3 @@
error: The absolute alignment offset (99) must be less than alignment size (4)
at section-align-large-ofs.asm(1)
Assembly aborted with 1 error!

View File

@@ -0,0 +1,2 @@
section union "fixed", wram0[$c001]
section union "fixed", wram0, align[1]

View File

@@ -0,0 +1,4 @@
error: Section already declared as fixed at incompatible address $c001
at union-mismatch.asm(2)
FATAL: Cannot create section "fixed" (1 error)
at union-mismatch.asm(2)