forked from KPGPMC/furlang
Improve AST nodes
Signed-off-by: CHatingPython <chatingpython@gmail.com>
This commit is contained in:
+2
-1
@@ -11,12 +11,13 @@ using namespace std::string_view_literals;
|
||||
#define EXPECT_EMPTY_TOKEN(lexer) EXPECT_EQ((lexer).next_token(), (token{}));
|
||||
|
||||
TEST(Lexer, Tokens) {
|
||||
lexer lexer("<TEMP>", "()\n\t\t{\n}[]; :,.main return func");
|
||||
lexer lexer("<TEMP>", "()\n\t\t{\n}[\"shto-to\"]; :,.main return func");
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Lparen, "("sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Rparen, ")"sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Lbrace, "{"sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Rbrace, "}"sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Lbracket, "["sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::String, "shto-to"sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Rbracket, "]"sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Semicolon, ";"sv }));
|
||||
EXPECT_TOKEN(lexer, (token{ token_t::Colon, ":"sv }));
|
||||
|
||||
@@ -16,7 +16,7 @@ TEST(Parser, EmptyFunctions) {
|
||||
{
|
||||
auto first = program->declarations()[0];
|
||||
EXPECT_TRUE(first.present());
|
||||
EXPECT_EQ(first->type(), declaration_node_t::FunctionDefinition);
|
||||
EXPECT_EQ(first->declaration_type(), declaration_node_t::FunctionDefinition);
|
||||
node_handle<function_definition_node> funcDef = first;
|
||||
EXPECT_EQ(funcDef->name().value, "main");
|
||||
EXPECT_EQ(funcDef->body()->statements.size(), 0);
|
||||
@@ -24,7 +24,7 @@ TEST(Parser, EmptyFunctions) {
|
||||
{
|
||||
auto second = program->declarations()[1];
|
||||
EXPECT_TRUE(second.present());
|
||||
EXPECT_EQ(second->type(), declaration_node_t::FunctionDeclaration);
|
||||
EXPECT_EQ(second->declaration_type(), declaration_node_t::FunctionDeclaration);
|
||||
node_handle<function_declarartion_node> funcDecl = second;
|
||||
EXPECT_EQ(funcDecl->name().value, "foo");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user