mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add more tests for RGBASM coverage
This commit is contained in:
@@ -41,7 +41,6 @@ struct Options {
|
||||
uint16_t height;
|
||||
uint32_t right() const { return left + width * 8; }
|
||||
uint32_t bottom() const { return top + height * 8; }
|
||||
bool specified() const { return left || top || width || height; }
|
||||
} inputSlice{0, 0, 0, 0}; // -L (margins in clockwise order, like CSS)
|
||||
uint8_t basePalID = 0; // -l
|
||||
std::array<uint16_t, 2> maxNbTiles{UINT16_MAX, 0}; // -N
|
||||
|
||||
@@ -632,7 +632,8 @@ static void verboseOutputConfig() {
|
||||
fputs("\t]\n", stderr);
|
||||
}
|
||||
// -L/--slice
|
||||
if (options.inputSlice.specified()) {
|
||||
if (options.inputSlice.width || options.inputSlice.height || options.inputSlice.left
|
||||
|| options.inputSlice.top) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"\tInput image slice: %" PRIu16 "x%" PRIu16 " pixels starting at (%" PRIu16 ", %" PRIu16
|
||||
|
||||
@@ -84,6 +84,8 @@ std::optional<uint64_t> parseNumber(char const *&str, NumberBase base) {
|
||||
// Identify the base if not specified
|
||||
// Does *not* support '+' or '-' sign prefix (unlike `strtoul` and `std::from_chars`)
|
||||
if (base == BASE_AUTO) {
|
||||
base = BASE_10;
|
||||
|
||||
// Skips leading blank space (like `strtoul`)
|
||||
str += strspn(str, " \t");
|
||||
|
||||
@@ -118,17 +120,10 @@ std::optional<uint64_t> parseNumber(char const *&str, NumberBase base) {
|
||||
base = BASE_16;
|
||||
str += 2;
|
||||
break;
|
||||
default:
|
||||
base = BASE_10;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
base = BASE_10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assume(base != BASE_AUTO);
|
||||
|
||||
// Get the digit-condition function corresponding to the base
|
||||
bool (*canParseDigit)(int c) = base == BASE_2 ? isBinDigit
|
||||
|
||||
15
test/asm/backtrace-collapsed.asm
Normal file
15
test/asm/backtrace-collapsed.asm
Normal file
@@ -0,0 +1,15 @@
|
||||
macro careful
|
||||
if _NARG == 20
|
||||
warn "You're in too deep!"
|
||||
else
|
||||
careful \#, deeper
|
||||
endc
|
||||
endm
|
||||
careful surface
|
||||
|
||||
macro recurse
|
||||
recurse
|
||||
endm
|
||||
rept 3
|
||||
recurse
|
||||
endr
|
||||
4
test/asm/backtrace-collapsed.err
Normal file
4
test/asm/backtrace-collapsed.err
Normal file
@@ -0,0 +1,4 @@
|
||||
warning: You're in too deep! [-Wuser]
|
||||
at backtrace-collapsed.asm::careful(3) <- backtrace-collapsed.asm::careful(5) <- backtrace-collapsed.asm::careful(5) <- ...16 more... <- backtrace-collapsed.asm::careful(5) <- backtrace-collapsed.asm(8)
|
||||
FATAL: Recursion limit (64) exceeded
|
||||
at backtrace-collapsed.asm::recurse(11) <- backtrace-collapsed.asm::recurse(11) <- backtrace-collapsed.asm::recurse(11) <- ...60 more... <- backtrace-collapsed.asm::REPT~1(14) <- backtrace-collapsed.asm(13)
|
||||
1
test/asm/backtrace-collapsed.flags
Normal file
1
test/asm/backtrace-collapsed.flags
Normal file
@@ -0,0 +1 @@
|
||||
-B 5 -B collapse
|
||||
1
test/asm/cli/empty-s-feature.err
Normal file
1
test/asm/cli/empty-s-feature.err
Normal file
@@ -0,0 +1 @@
|
||||
FATAL: Empty feature for option '-s'
|
||||
1
test/asm/cli/empty-s-feature.flags
Normal file
1
test/asm/cli/empty-s-feature.flags
Normal file
@@ -0,0 +1 @@
|
||||
-s :-
|
||||
@@ -1 +1 @@
|
||||
--color yes
|
||||
--color=always --color=never --color=auto --color=yes
|
||||
|
||||
1
test/asm/cli/invalid-s-feature.err
Normal file
1
test/asm/cli/invalid-s-feature.err
Normal file
@@ -0,0 +1 @@
|
||||
FATAL: Invalid feature for option '-s': "invalid"
|
||||
1
test/asm/cli/invalid-s-feature.flags
Normal file
1
test/asm/cli/invalid-s-feature.flags
Normal file
@@ -0,0 +1 @@
|
||||
-s invalid:-
|
||||
10
test/asm/disable-warnings.asm
Normal file
10
test/asm/disable-warnings.asm
Normal file
@@ -0,0 +1,10 @@
|
||||
MACRO test
|
||||
assert warn, 0, "-Wassert is on by default"
|
||||
warn "-Wuser is on by default"
|
||||
ENDM
|
||||
|
||||
test ; no warnings because of -w
|
||||
OPT -Weverything
|
||||
test ; still no warnings because of -w
|
||||
OPT Werror=everything
|
||||
test ; now errors can occur
|
||||
1
test/asm/disable-warnings.flags
Normal file
1
test/asm/disable-warnings.flags
Normal file
@@ -0,0 +1 @@
|
||||
-w
|
||||
@@ -1 +1 @@
|
||||
-B all
|
||||
-B no-all -B all
|
||||
|
||||
0
test/asm/make-deps.asm
Normal file
0
test/asm/make-deps.asm
Normal file
1
test/asm/make-deps.flags
Normal file
1
test/asm/make-deps.flags
Normal file
@@ -0,0 +1 @@
|
||||
-M - -MT preserve$dollars$$ -MQ escape$dollars$$
|
||||
1
test/asm/make-deps.out
Normal file
1
test/asm/make-deps.out
Normal file
@@ -0,0 +1 @@
|
||||
preserve$dollars$$ escape$$dollars$$$$: make-deps.asm
|
||||
1
test/asm/opt-r.flags
Normal file
1
test/asm/opt-r.flags
Normal file
@@ -0,0 +1 @@
|
||||
-r9 -r$f -r%1 -r&7 -r0xFF -r0b11 -r0o77 -r64
|
||||
7
test/asm/state-features.asm
Normal file
7
test/asm/state-features.asm
Normal file
@@ -0,0 +1,7 @@
|
||||
MACRO one
|
||||
!@#$%^&* /* anything */ :'<,>./? ; goes!
|
||||
ENDM
|
||||
CHARMAP "char", 2, 3
|
||||
DEF string EQUS "four"
|
||||
DEF variable = 5
|
||||
DEF constant EQU 6
|
||||
2
test/asm/state-features.err
Normal file
2
test/asm/state-features.err
Normal file
@@ -0,0 +1,2 @@
|
||||
warning: Ignoring duplicate feature for option '-s': "equ"
|
||||
warning: Redundant feature before "all" for option '-s'
|
||||
1
test/asm/state-features.flags
Normal file
1
test/asm/state-features.flags
Normal file
@@ -0,0 +1 @@
|
||||
-s equ,var,equ,all:-
|
||||
19
test/asm/state-features.out
Normal file
19
test/asm/state-features.out
Normal file
@@ -0,0 +1,19 @@
|
||||
; File generated by rgbasm
|
||||
|
||||
; Numeric constants
|
||||
def constant equ $6
|
||||
|
||||
; Variables
|
||||
def variable = $5
|
||||
|
||||
; String constants
|
||||
def string equs "four"
|
||||
|
||||
; Character maps
|
||||
newcharmap main
|
||||
charmap "char", $2, $3
|
||||
|
||||
; Macros
|
||||
macro one
|
||||
!@#$%^&* /* anything */ :'<,>./? ; goes!
|
||||
endm
|
||||
@@ -84,10 +84,11 @@ for i in *.asm notexist.asm; do
|
||||
desired_output=$desired_outname
|
||||
desired_errput=$desired_errname
|
||||
else
|
||||
# `include-recursion.asm` refers to its own name inside the test code.
|
||||
# "notexist" doesn't exist, so there's no point in trying to `cat` it.
|
||||
# Skip testing with stdin input for those file.
|
||||
if [[ "$i" = include-recursion.asm || "$i" = notexist.asm ]]; then
|
||||
# "include-recursion.asm" refers to its own name inside the test code.
|
||||
# "make-deps.asm" refers to its output filename in its desired output.
|
||||
# "notexist.asm" doesn't exist, so there's no point in trying to `cat` it.
|
||||
# Skip testing with stdin input for those files.
|
||||
if [[ "$i" = include-recursion.asm || "$i" = make-deps.asm || "$i" = notexist.asm ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -193,18 +194,20 @@ i="state-file"
|
||||
if which cygpath &>/dev/null; then
|
||||
# MinGW translates path names before passing them as command-line arguments,
|
||||
# but does not do so when they are prefixed, so we have to do it ourselves.
|
||||
RGBASMFLAGS="-Weverything -Bcollapse -s all:$(cygpath -w "$o")"
|
||||
state_outname="$(cygpath -w "$o")"
|
||||
else
|
||||
RGBASMFLAGS="-Weverything -Bcollapse -s all:$o"
|
||||
state_outname="$o"
|
||||
fi
|
||||
state_features=" all " # Test trimming whitespace
|
||||
RGBASMFLAGS="-Weverything -Bcollapse"
|
||||
for variant in '' '.pipe'; do
|
||||
(( tests++ ))
|
||||
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
|
||||
if [ -z "$variant" ]; then
|
||||
"$RGBASM" $RGBASMFLAGS "$i"/a.asm >"$output" 2>"$errput"
|
||||
"$RGBASM" $RGBASMFLAGS -s "$state_features:$state_outname" "$i"/a.asm >"$output" 2>"$errput"
|
||||
else
|
||||
# shellcheck disable=SC2002
|
||||
cat "$i"/a.asm | "$RGBASM" $RGBASMFLAGS - >"$output" 2>"$errput"
|
||||
cat "$i"/a.asm | "$RGBASM" $RGBASMFLAGS -s "$state_features:$state_outname" - >"$output" 2>"$errput"
|
||||
fi
|
||||
|
||||
tryDiff /dev/null "$output" out
|
||||
|
||||
0
test/asm/unknown-warning.asm
Normal file
0
test/asm/unknown-warning.asm
Normal file
2
test/asm/unknown-warning.err
Normal file
2
test/asm/unknown-warning.err
Normal file
@@ -0,0 +1,2 @@
|
||||
warning: Unknown warning flag "noexist"
|
||||
warning: Unknown warning flag parameter "noexistparam=2"
|
||||
1
test/asm/unknown-warning.flags
Normal file
1
test/asm/unknown-warning.flags
Normal file
@@ -0,0 +1 @@
|
||||
-Wnoexist -Wnoexistparam=2
|
||||
14
test/asm/warning-as-error.asm
Normal file
14
test/asm/warning-as-error.asm
Normal file
@@ -0,0 +1,14 @@
|
||||
DEF n = -99 >> 1 ; -Wshift
|
||||
DEF n = 999_999_999_999 ; -Wlarge-constant
|
||||
|
||||
MACRO test
|
||||
WARN "warning or error?"
|
||||
ENDM
|
||||
|
||||
test
|
||||
|
||||
OPT Werror
|
||||
test
|
||||
|
||||
OPT Wno-error
|
||||
test
|
||||
10
test/asm/warning-as-error.err
Normal file
10
test/asm/warning-as-error.err
Normal file
@@ -0,0 +1,10 @@
|
||||
warning: Shifting right negative value -99 [-Wshift]
|
||||
at warning-as-error.asm(1)
|
||||
error: Integer constant is too large [-Werror=large-constant]
|
||||
at warning-as-error.asm(2)
|
||||
warning: warning or error? [-Wuser]
|
||||
at warning-as-error.asm::test(5) <- warning-as-error.asm(8)
|
||||
error: warning or error? [-Werror=user]
|
||||
at warning-as-error.asm::test(5) <- warning-as-error.asm(11)
|
||||
warning: warning or error? [-Wuser]
|
||||
at warning-as-error.asm::test(5) <- warning-as-error.asm(14)
|
||||
1
test/asm/warning-as-error.flags
Normal file
1
test/asm/warning-as-error.flags
Normal file
@@ -0,0 +1 @@
|
||||
-Werror=shift -Wno-error=shift -Werror=large-constant
|
||||
Reference in New Issue
Block a user