Implements basic virtprop parsing.

This commit is contained in:
2020-10-31 19:23:15 +01:00
parent 6a0ec63a7e
commit 823b00777e
6 changed files with 199 additions and 29 deletions

View File

@@ -32,3 +32,15 @@ PARSE_TEST("Parse function without definition", "void foobar(int8 par1, bool &in
REQUIRE(script->GetStatements().size() == 1);
REQUIRE(script->GetStatements()[0].get()->GetKind() == Parser::ParsedStatementKind::Func);
})
PARSE_TEST("Parse class with virtprop", "class foobar { private bool foo { get; set; } }", {
REQUIRE(diags.GetMessages().empty());
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::Private);
REQUIRE(virtPropStatement->GetIdentifier().GetString() == u8"foo");
})