c051f5d3e7
* patterns: Rewrite most of the evaluator to mainly use polymorphism instead of just RTTI * patterns: Fixed a couple of AST memory leaks * patterns: Parse string operations correctly * patterns: Various fixes and cleanup * patterns: Implement primitive function definitions Function parameters now need to provide their type in the definition * patterns: Added function variable definition and assignment * patterns: Added remaining function statements * patterns: Added unsized and while-sized arrays * patterns: Added multi variable declarations to functions * patterns: Added std::format built-in function * patterns: Allow passing custom types to functions * patterns: Added attributes and new "format" attribute * patterns: Use libfmt for std::print instead of custom version * patterns: Remove unnecessary string compare function * pattern: Fix preprocessor directives * patterns: Fix unit tests * patterns: Added cast expression * patterns: Handle endianess in function parameters * patterns: Added casting to different endian * patterns: Added 'str' type for functions
32 lines
784 B
C++
32 lines
784 B
C++
#pragma once
|
|
|
|
#include "test_pattern.hpp"
|
|
|
|
namespace hex::test {
|
|
|
|
class TestPatternLiterals : public TestPattern {
|
|
public:
|
|
TestPatternLiterals() : TestPattern("Literals") {
|
|
|
|
}
|
|
~TestPatternLiterals() override = default;
|
|
|
|
[[nodiscard]]
|
|
std::string getSourceCode() const override {
|
|
return R"(
|
|
#define MSG "Invalid literal"
|
|
|
|
std::assert(255 == 0xFF, MSG);
|
|
std::assert(0xAA == 0b10101010, MSG);
|
|
std::assert(12345 != 67890, MSG);
|
|
std::assert(100U == 0x64U, MSG);
|
|
std::assert(-100 == -0x64, MSG);
|
|
std::assert(3.14159F > 1.414D, MSG);
|
|
std::assert('A' == 0x41, MSG);
|
|
|
|
)";
|
|
}
|
|
|
|
};
|
|
|
|
} |