mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 02:02:06 +00:00
Increase test coverage (#1661)
This commit is contained in:
@@ -18,12 +18,10 @@
|
|||||||
#include "gfx/main.hpp"
|
#include "gfx/main.hpp"
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
// Construct a `std::streambuf *` by default, since it's probably lighter than a `filebuf`.
|
|
||||||
Either<std::streambuf *, std::filebuf> _file;
|
Either<std::streambuf *, std::filebuf> _file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
File() {}
|
File() : _file(nullptr) {}
|
||||||
~File() { close(); }
|
|
||||||
|
|
||||||
// This should only be called once, and before doing any `->` operations.
|
// This should only be called once, and before doing any `->` operations.
|
||||||
// Returns `nullptr` on error, and a non-null pointer otherwise.
|
// Returns `nullptr` on error, and a non-null pointer otherwise.
|
||||||
@@ -61,20 +59,6 @@ public:
|
|||||||
return const_cast<File *>(this)->operator->();
|
return const_cast<File *>(this)->operator->();
|
||||||
}
|
}
|
||||||
|
|
||||||
File *close() {
|
|
||||||
if (_file.holds<std::filebuf>()) {
|
|
||||||
// This is called by the destructor, and an explicit `close` shouldn't close twice.
|
|
||||||
std::filebuf fileBuf = std::move(_file.get<std::filebuf>());
|
|
||||||
_file.emplace<std::streambuf *>(nullptr);
|
|
||||||
if (fileBuf.close() != nullptr) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
} else if (_file.get<std::streambuf *>() != nullptr) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char const *c_str(std::string const &path) const {
|
char const *c_str(std::string const &path) const {
|
||||||
return _file.holds<std::filebuf>() ? path.c_str()
|
return _file.holds<std::filebuf>() ? path.c_str()
|
||||||
: _file.get<std::streambuf *>() == std::cin.rdbuf() ? "<stdin>"
|
: _file.get<std::streambuf *>() == std::cin.rdbuf() ? "<stdin>"
|
||||||
|
|||||||
@@ -358,7 +358,8 @@ void Expression::makeUnaryOp(RPNCommand op, Expression &&src) {
|
|||||||
case RPN_BIT_INDEX:
|
case RPN_BIT_INDEX:
|
||||||
case RPN_CONST:
|
case RPN_CONST:
|
||||||
case RPN_SYM:
|
case RPN_SYM:
|
||||||
fatalerror("%d is not an unary operator\n", op);
|
// `makeUnaryOp` should never be called with a non-unary operator!
|
||||||
|
unreachable_();
|
||||||
}
|
}
|
||||||
} else if (op == RPN_LOGNOT && tryConstLogNot(src)) {
|
} else if (op == RPN_LOGNOT && tryConstLogNot(src)) {
|
||||||
data = 0;
|
data = 0;
|
||||||
@@ -522,7 +523,8 @@ void Expression::makeBinaryOp(RPNCommand op, Expression &&src1, Expression const
|
|||||||
case RPN_TZCOUNT:
|
case RPN_TZCOUNT:
|
||||||
case RPN_CONST:
|
case RPN_CONST:
|
||||||
case RPN_SYM:
|
case RPN_SYM:
|
||||||
fatalerror("%d is not a binary operator\n", op);
|
// `makeBinaryOp` should never be called with a non-binary operator!
|
||||||
|
unreachable_();
|
||||||
}
|
}
|
||||||
} else if (op == RPN_SUB && src1.isDiffConstant(src2.symbolOf())) {
|
} else if (op == RPN_SUB && src1.isDiffConstant(src2.symbolOf())) {
|
||||||
data = src1.symbolOf()->getValue() - src2.symbolOf()->getValue();
|
data = src1.symbolOf()->getValue() - src2.symbolOf()->getValue();
|
||||||
|
|||||||
@@ -15,3 +15,6 @@ SECTION "Unaligned", ROM0
|
|||||||
|
|
||||||
println @ & 0
|
println @ & 0
|
||||||
println @ & 1 ; Nope
|
println @ & 1 ; Nope
|
||||||
|
|
||||||
|
Floating:
|
||||||
|
println Floating & Aligned ; Neither defined
|
||||||
|
|||||||
@@ -4,4 +4,6 @@ error: const-and.asm(11):
|
|||||||
Expected constant expression: 'Aligned' is not constant at assembly time
|
Expected constant expression: 'Aligned' is not constant at assembly time
|
||||||
error: const-and.asm(17):
|
error: const-and.asm(17):
|
||||||
Expected constant expression: PC is not constant at assembly time
|
Expected constant expression: PC is not constant at assembly time
|
||||||
error: Assembly aborted (3 errors)!
|
error: const-and.asm(20):
|
||||||
|
Expected constant expression: 'Floating' is not constant at assembly time
|
||||||
|
error: Assembly aborted (4 errors)!
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ $0
|
|||||||
$A
|
$A
|
||||||
$0
|
$0
|
||||||
$0
|
$0
|
||||||
|
$0
|
||||||
|
|||||||
Reference in New Issue
Block a user