|
|
|
@ -13,7 +13,7 @@ using namespace MalachScript;
|
|
|
|
|
vec[i]->SetNext(vec[i + 1]); \
|
|
|
|
|
} \
|
|
|
|
|
Diagnostics::Logger diags; \
|
|
|
|
|
auto* script = Parser::Parser::Parse(vec.front(), "scriptname", &diags); \
|
|
|
|
|
auto* script = Parser::Parser::Parse(vec.front(), &diags); \
|
|
|
|
|
REQUIRE(diags.GetMessages().empty()); \
|
|
|
|
|
asserts; \
|
|
|
|
|
delete vec[0]; \
|
|
|
|
@ -21,113 +21,111 @@ using namespace MalachScript;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PARSER_TEST_TOKENS(...) __VA_ARGS__
|
|
|
|
|
#define TextSpan(a, b) ScriptTextSpan(a, b, "")
|
|
|
|
|
|
|
|
|
|
PARSER_TEST(
|
|
|
|
|
"Parse class foobar { bool foo { get; set; } }",
|
|
|
|
|
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "bool"),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[0].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() == nullptr);
|
|
|
|
|
})
|
|
|
|
|
PARSER_TEST("Parse class foobar { bool foo { get; set; } }",
|
|
|
|
|
PARSER_TEST_TOKENS(
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "bool"), new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[0].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() == nullptr);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
PARSER_TEST(
|
|
|
|
|
"Parse class foobar { bool foo { get const; set const; } }",
|
|
|
|
|
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "bool"),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[0].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() == nullptr);
|
|
|
|
|
})
|
|
|
|
|
PARSER_TEST("Parse class foobar { bool foo { get const; set const; } }",
|
|
|
|
|
PARSER_TEST_TOKENS(
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "bool"), new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[0].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() == nullptr);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
PARSER_TEST(
|
|
|
|
|
"Parse class foobar { bool foo { get const override; set const override; } }",
|
|
|
|
|
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "bool"),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OverrideKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OverrideKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[0].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(FuncAttrHelpers::Contains(virtPropStatement->GetGetFuncAttr(), FuncAttr::Override));
|
|
|
|
|
REQUIRE(FuncAttrHelpers::Contains(virtPropStatement->GetSetFuncAttr(), FuncAttr::Override));
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() == nullptr);
|
|
|
|
|
})
|
|
|
|
|
PARSER_TEST("Parse class foobar { bool foo { get const override; set const override; } }",
|
|
|
|
|
PARSER_TEST_TOKENS(
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "bool"), new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OverrideKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OverrideKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[0].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(FuncAttrHelpers::Contains(virtPropStatement->GetGetFuncAttr(), FuncAttr::Override));
|
|
|
|
|
REQUIRE(FuncAttrHelpers::Contains(virtPropStatement->GetSetFuncAttr(), FuncAttr::Override));
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() == nullptr);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/// class foobar {
|
|
|
|
|
// int i;
|
|
|
|
@ -143,9 +141,8 @@ PARSER_TEST(
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
PARSER_TEST(
|
|
|
|
|
"Virtprops with bodies",
|
|
|
|
|
PARSER_TEST_TOKENS(
|
|
|
|
|
PARSER_TEST("Virtprops with bodies",
|
|
|
|
|
PARSER_TEST_TOKENS(
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
@ -164,8 +161,8 @@ PARSER_TEST(
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::TrueKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::ReturnKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::FalseKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::FalseKeyword>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
|
|
|
|
@ -186,21 +183,21 @@ PARSER_TEST(
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
|
|
|
|
|
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[1].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() != nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() != nullptr);
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(script->GetStatements().size() == 1);
|
|
|
|
|
auto firstStatement = script->GetStatements()[0].get();
|
|
|
|
|
REQUIRE(firstStatement->GetKind() == Parser::ParsedStatementKind::Class);
|
|
|
|
|
auto firstClassStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedClassStatement*>(firstStatement)->GetBody()[1].get();
|
|
|
|
|
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
|
|
|
|
|
auto virtPropStatement =
|
|
|
|
|
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
|
|
|
|
|
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
|
|
|
|
|
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
|
|
|
|
|
REQUIRE(virtPropStatement->HasGet());
|
|
|
|
|
REQUIRE(virtPropStatement->HasSet());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsGetConst());
|
|
|
|
|
REQUIRE_FALSE(virtPropStatement->IsSetConst());
|
|
|
|
|
REQUIRE(virtPropStatement->GetGetStatement() != nullptr);
|
|
|
|
|
REQUIRE(virtPropStatement->GetSetStatement() != nullptr);
|
|
|
|
|
})
|