Skip to content

Commit e8c2be5

Browse files
authored
chore: added no action test (#48)
1 parent cea7209 commit e8c2be5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

runtime/test/runtime_test.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ void runtime_test::MakeAnother::impl(context& ctx) {
3636
ctx._ctx.generate(ctx.get<ComponentA>());
3737
}
3838

39+
void runtime_test::TestAction::impl(context& ctx) {
40+
}
41+
3942
void runtime_test::AlwaysRemove::impl(context& ctx) {
4043
// This trivial remove should not even be required:
4144
// SEE: https://github.com/ecsact-dev/ecsact_lang_cpp/issues/80
@@ -797,6 +800,36 @@ TEST(Core, MultiPkgUpdate) {
797800
}
798801
}
799802

803+
TEST(Core, NoAction) {
804+
static bool action_executed = false;
805+
806+
ASSERT_TRUE(ecsact_set_system_execution_impl(
807+
ecsact_id_cast<ecsact_system_like_id>(runtime_test::TestAction::id),
808+
[](ecsact_system_execution_context*) { action_executed = true; }
809+
));
810+
811+
auto reg = ecsact::core::registry("Core_NoAction");
812+
813+
auto test_entity = reg.create_entity();
814+
reg.add_component(test_entity, runtime_test::ComponentA{});
815+
816+
reg.execute_systems();
817+
818+
ASSERT_FALSE(action_executed);
819+
820+
auto exec_opts = ecsact::core::execution_options{};
821+
822+
auto exec_err = reg.execute_systems(std::array{exec_opts});
823+
ASSERT_EQ(exec_err, ECSACT_EXEC_SYS_OK);
824+
ASSERT_FALSE(action_executed);
825+
826+
auto evc = ecsact::core::execution_events_collector<>{};
827+
828+
exec_err = reg.execute_systems(std::array{exec_opts}, evc);
829+
ASSERT_EQ(exec_err, ECSACT_EXEC_SYS_OK);
830+
ASSERT_FALSE(action_executed);
831+
}
832+
800833
#ifdef ECSACT_ENTT_TEST_STATIC_SYSTEM_IMPL
801834
TEST(Core, StaticSystemImpl) {
802835
auto reg_id = ecsact_create_registry("StaticSystemImpl");

runtime/test/runtime_test.ecsact

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ action AssocTestAction {
6161
adds OtherEntityComponent;
6262
}
6363

64+
action TestAction {
65+
readwrite ComponentA;
66+
}
67+
6468
component AddAssocTestComponent {
6569
i32 num;
6670
}

0 commit comments

Comments
 (0)