Cleanup of parser class.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,7 +5,7 @@ using namespace MalachScript::Parser;
|
||||
|
||||
#define KEYWORD_TEST(script, symbol) \
|
||||
TEST_CASE("Lex " script) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##script, u8##script, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
@@ -92,7 +92,7 @@ namespace doctest {
|
||||
|
||||
#define IDENTIFIER_TEST(identifier) \
|
||||
TEST_CASE("Lex identifier " identifier) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##identifier, u8##identifier, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
|
||||
@@ -5,7 +5,7 @@ using namespace MalachScript::Parser;
|
||||
|
||||
#define LEX_TEST(script, ...) \
|
||||
TEST_CASE("Lex: " script) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##script, u8##script, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
|
||||
@@ -5,7 +5,7 @@ using namespace MalachScript::Parser;
|
||||
|
||||
#define INTEGER_TEST(script, expected) \
|
||||
TEST_CASE("Lex " script) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##script, u8##script, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
@@ -17,7 +17,7 @@ using namespace MalachScript::Parser;
|
||||
|
||||
#define FLOAT_TEST(script, expected) \
|
||||
TEST_CASE("Lex " script) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##script, u8##script, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
@@ -72,7 +72,7 @@ INTEGER_TEST("0B110011", 51);
|
||||
#undef FLOAT_TEST
|
||||
|
||||
TEST_CASE("Lex invalid numerical base") {
|
||||
MalachScript::Diagnostics::Diagnostics diag;
|
||||
MalachScript::Diagnostics::Logger diag;
|
||||
auto lexer = Lexer(u8"bad base", u8"0f553", &diag);
|
||||
lexer.Lex();
|
||||
const auto& messages = diag.GetMessages();
|
||||
|
||||
@@ -5,7 +5,7 @@ using namespace MalachScript::Parser;
|
||||
|
||||
#define STRING_TEST(str, constraint) \
|
||||
TEST_CASE("Lex string " constraint str constraint) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##str, u8##constraint str constraint, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
@@ -22,7 +22,7 @@ STRING_TEST("\"foo bar\"", "\"\"\"");
|
||||
STRING_TEST("\"\"foo bar\"\"", "\"\"\"");
|
||||
|
||||
TEST_CASE("Lex multiline string") {
|
||||
MalachScript::Diagnostics::Diagnostics diag;
|
||||
MalachScript::Diagnostics::Logger diag;
|
||||
auto lexer = Lexer(u8"multiline", u8R"("""foo
|
||||
bar""")",
|
||||
&diag);
|
||||
|
||||
@@ -6,7 +6,7 @@ using namespace MalachScript::Parser;
|
||||
|
||||
#define SYMBOL_TEST(script, symbol) \
|
||||
TEST_CASE("Lex " script) { \
|
||||
MalachScript::Diagnostics::Diagnostics diag; \
|
||||
MalachScript::Diagnostics::Logger diag; \
|
||||
auto lexer = Lexer(u8##script, u8##script, &diag); \
|
||||
const auto* token = lexer.Lex(); \
|
||||
CHECK(diag.GetMessages().empty()); \
|
||||
@@ -73,7 +73,7 @@ SYMBOL_TEST(" ", Whitespace)
|
||||
TEST_CASE("Lex whitespace") {
|
||||
auto whitespace = {u8" ", u8"\t", u8"\n", u8"\r", u8"\xef\xbb\xbf"};
|
||||
for (const auto* v : whitespace) {
|
||||
MalachScript::Diagnostics::Diagnostics diag;
|
||||
MalachScript::Diagnostics::Logger diag;
|
||||
auto lexer = Lexer(u8"whitespace", v, &diag);
|
||||
const auto* token = lexer.Lex();
|
||||
CHECK(diag.GetMessages().empty());
|
||||
|
||||
Reference in New Issue
Block a user