mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
chore: change tests to reflect new action parsing behaviour
This commit is contained in:
parent
89074c8601
commit
666ea2be9d
@ -17,11 +17,12 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
std::unique_ptr<CommandsParserState> m_state;
|
std::unique_ptr<CommandsParserState> m_state;
|
||||||
std::unique_ptr<ILexer<CommandsParserValue>> m_lexer;
|
std::unique_ptr<ILexer<CommandsParserValue>> m_lexer;
|
||||||
|
|
||||||
StructDefinition* m_test_struct_raw;
|
StructDefinition* m_test_struct_t;
|
||||||
StructureInformation* m_test_struct;
|
StructureInformation* m_test_struct;
|
||||||
|
|
||||||
StructDefinition* m_test_struct2_raw;
|
StructDefinition* m_container_struct_t;
|
||||||
StructureInformation* m_test_struct2;
|
StructureInformation* m_container_struct;
|
||||||
|
MemberInformation* m_container_struct_child;
|
||||||
|
|
||||||
StructDefinition* m_arg_struct_raw;
|
StructDefinition* m_arg_struct_raw;
|
||||||
StructureInformation* m_arg_struct;
|
StructureInformation* m_arg_struct;
|
||||||
@ -37,10 +38,12 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
private:
|
private:
|
||||||
void RetrieveInformationPointers()
|
void RetrieveInformationPointers()
|
||||||
{
|
{
|
||||||
m_test_struct = m_repository->GetInformationFor(m_test_struct_raw);
|
m_test_struct = m_repository->GetInformationFor(m_test_struct_t);
|
||||||
REQUIRE(m_test_struct != nullptr);
|
REQUIRE(m_test_struct != nullptr);
|
||||||
m_test_struct2 = m_repository->GetInformationFor(m_test_struct2_raw);
|
m_container_struct = m_repository->GetInformationFor(m_container_struct_t);
|
||||||
REQUIRE(m_test_struct2 != nullptr);
|
REQUIRE(m_container_struct != nullptr);
|
||||||
|
m_container_struct_child = m_container_struct->m_ordered_members[0].get();
|
||||||
|
REQUIRE(m_container_struct_child != nullptr);
|
||||||
m_arg_struct = m_repository->GetInformationFor(m_arg_struct_raw);
|
m_arg_struct = m_repository->GetInformationFor(m_arg_struct_raw);
|
||||||
REQUIRE(m_arg_struct != nullptr);
|
REQUIRE(m_arg_struct != nullptr);
|
||||||
m_arg_struct2 = m_repository->GetInformationFor(m_arg_struct2_raw);
|
m_arg_struct2 = m_repository->GetInformationFor(m_arg_struct2_raw);
|
||||||
@ -61,12 +64,12 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
{
|
{
|
||||||
auto def = std::make_unique<StructDefinition>("", "test_struct_t", 8);
|
auto def = std::make_unique<StructDefinition>("", "test_struct_t", 8);
|
||||||
def->m_members.emplace_back(std::make_shared<Variable>("m_test", std::make_unique<TypeDeclaration>(BaseTypeDefinition::BOOL)));
|
def->m_members.emplace_back(std::make_shared<Variable>("m_test", std::make_unique<TypeDeclaration>(BaseTypeDefinition::BOOL)));
|
||||||
m_test_struct_raw = def.get();
|
m_test_struct_t = def.get();
|
||||||
m_repository->Add(std::move(def));
|
m_repository->Add(std::move(def));
|
||||||
|
|
||||||
def = std::make_unique<StructDefinition>("", "container_struct_t", 8);
|
def = std::make_unique<StructDefinition>("", "container_struct_t", 8);
|
||||||
def->m_members.emplace_back(std::make_shared<Variable>("m_child", std::make_unique<TypeDeclaration>(m_test_struct_raw)));
|
def->m_members.emplace_back(std::make_shared<Variable>("m_child", std::make_unique<TypeDeclaration>(m_test_struct_t)));
|
||||||
m_test_struct2_raw = def.get();
|
m_container_struct_t = def.get();
|
||||||
m_repository->Add(std::move(def));
|
m_repository->Add(std::move(def));
|
||||||
|
|
||||||
def = std::make_unique<StructDefinition>("", "arg_t", 8);
|
def = std::make_unique<StructDefinition>("", "arg_t", 8);
|
||||||
@ -91,10 +94,10 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
CommandsSequenceTestsHelper()
|
CommandsSequenceTestsHelper()
|
||||||
: m_repository(std::make_unique<InMemoryRepository>()),
|
: m_repository(std::make_unique<InMemoryRepository>()),
|
||||||
m_state(std::make_unique<CommandsParserState>(m_repository.get())),
|
m_state(std::make_unique<CommandsParserState>(m_repository.get())),
|
||||||
m_test_struct_raw(nullptr),
|
m_test_struct_t(nullptr),
|
||||||
m_test_struct(nullptr),
|
m_test_struct(nullptr),
|
||||||
m_test_struct2_raw(nullptr),
|
m_container_struct_t(nullptr),
|
||||||
m_test_struct2(nullptr),
|
m_container_struct(nullptr),
|
||||||
m_arg_struct_raw(nullptr),
|
m_arg_struct_raw(nullptr),
|
||||||
m_arg_struct(nullptr),
|
m_arg_struct(nullptr),
|
||||||
m_arg_struct2_raw(nullptr),
|
m_arg_struct2_raw(nullptr),
|
||||||
@ -339,9 +342,11 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
|
|
||||||
REQUIRE(result);
|
REQUIRE(result);
|
||||||
REQUIRE(helper.m_consumed_token_count == 10);
|
REQUIRE(helper.m_consumed_token_count == 10);
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action);
|
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action->m_action_name == "TestMethod");
|
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action->m_parameter_types.empty());
|
REQUIRE(helper.m_container_struct_child->m_post_load_action);
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action->m_action_name == "TestMethod");
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action->m_parameter_types.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("SequenceAction: Ensure can parse action directive with type from member and in use", "[parsing][sequence]")
|
TEST_CASE("SequenceAction: Ensure can parse action directive with type from member and in use", "[parsing][sequence]")
|
||||||
@ -358,15 +363,17 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
CommandsParserValue::Character(pos, ';'),
|
CommandsParserValue::Character(pos, ';'),
|
||||||
CommandsParserValue::EndOfFile(pos),
|
CommandsParserValue::EndOfFile(pos),
|
||||||
});
|
});
|
||||||
helper.m_state->SetInUse(helper.m_test_struct2);
|
helper.m_state->SetInUse(helper.m_container_struct);
|
||||||
|
|
||||||
auto result = helper.PerformTest();
|
auto result = helper.PerformTest();
|
||||||
|
|
||||||
REQUIRE(result);
|
REQUIRE(result);
|
||||||
REQUIRE(helper.m_consumed_token_count == 7);
|
REQUIRE(helper.m_consumed_token_count == 7);
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action);
|
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action->m_action_name == "TestMethod");
|
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action->m_parameter_types.empty());
|
REQUIRE(helper.m_container_struct_child->m_post_load_action);
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action->m_action_name == "TestMethod");
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action->m_parameter_types.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("SequenceAction: Ensure can use different struct even though something is used", "[parsing][sequence]")
|
TEST_CASE("SequenceAction: Ensure can use different struct even though something is used", "[parsing][sequence]")
|
||||||
@ -392,30 +399,10 @@ namespace test::parsing::commands::sequence::sequence_action
|
|||||||
|
|
||||||
REQUIRE(result);
|
REQUIRE(result);
|
||||||
REQUIRE(helper.m_consumed_token_count == 10);
|
REQUIRE(helper.m_consumed_token_count == 10);
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action);
|
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action->m_action_name == "TestMethod");
|
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action->m_parameter_types.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("SequenceAction: Ensure member must be type with members", "[parsing][sequence]")
|
|
||||||
{
|
|
||||||
CommandsSequenceTestsHelper helper;
|
|
||||||
const TokenPos pos;
|
|
||||||
helper.Tokens({
|
|
||||||
CommandsParserValue::Identifier(pos, new std::string("set")),
|
|
||||||
CommandsParserValue::Identifier(pos, new std::string("action")),
|
|
||||||
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
|
|
||||||
CommandsParserValue::Character(pos, ':'),
|
|
||||||
CommandsParserValue::Character(pos, ':'),
|
|
||||||
CommandsParserValue::Identifier(pos, new std::string("m_test")),
|
|
||||||
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
|
|
||||||
CommandsParserValue::Character(pos, '('),
|
|
||||||
CommandsParserValue::Character(pos, ')'),
|
|
||||||
CommandsParserValue::Character(pos, ';'),
|
|
||||||
CommandsParserValue::EndOfFile(pos),
|
|
||||||
});
|
|
||||||
|
|
||||||
REQUIRE_THROWS_AS(helper.PerformTest(), ParsingException);
|
|
||||||
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
|
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
|
||||||
|
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action);
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action->m_action_name == "TestMethod");
|
||||||
|
REQUIRE(helper.m_container_struct_child->m_post_load_action->m_parameter_types.empty());
|
||||||
}
|
}
|
||||||
} // namespace test::parsing::commands::sequence::sequence_action
|
} // namespace test::parsing::commands::sequence::sequence_action
|
||||||
|
Loading…
x
Reference in New Issue
Block a user