Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: test anonymous system #166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,19 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "anonymous_system",
srcs = ["anonymous_system.cc"],
copts = copts,
data = [
"anonymous_system.ecsact",
],
deps = [
":test_lib",
"//:ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
32 changes: 32 additions & 0 deletions test/anonymous_system.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"
#include "ecsact/runtime/meta.hh"

#include "test/test_lib.hh"

TEST(EcsactInterpret, AllowAnonymousSystem) {
auto errs = ecsact_interpret_test_files({"anonymous_system.ecsact"});
ASSERT_EQ(errs.size(), 0) //
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n";

auto package_ids = ecsact::meta::get_package_ids();
ASSERT_EQ(package_ids.size(), 1);

auto sys_ids = ecsact::meta::get_system_ids(package_ids[0]);
ASSERT_EQ(sys_ids.size(), 1);

auto sys_name = ecsact::meta::system_name(sys_ids[0]);
ASSERT_TRUE(sys_name.empty());

auto sys_caps = ecsact::meta::system_capabilities(sys_ids[0]);
ASSERT_EQ(sys_caps.size(), 1);

auto comp_ids = ecsact::meta::get_component_ids(package_ids[0]);
ASSERT_EQ(comp_ids.size(), 1);

ASSERT_EQ(sys_caps.begin()->second, ECSACT_SYS_CAP_REMOVES);
ASSERT_EQ(
sys_caps.begin()->first,
ecsact_id_cast<ecsact_component_like_id>(comp_ids[0])
);
}
7 changes: 7 additions & 0 deletions test/anonymous_system.ecsact
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package example.anonymous_sys;

component MyComponent;

// Trival anonymous system that always removes MyComponent
system { removes MyComponent; }