-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new component type apis (#240)
- Loading branch information
Showing
11 changed files
with
188 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "gtest/gtest.h" | ||
#include "ecsact/interpret/eval.h" | ||
|
||
#include "test_lib.hh" | ||
|
||
TEST(UnknownParamValue, UnknownStreamComponentParamValue) { | ||
auto errs = ecsact_interpret_test_files({ | ||
"errors/invalid_stream_component_param_value.ecsact", | ||
}); | ||
ASSERT_EQ(errs.size(), 1); | ||
ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_INVALID_PARAMETER_VALUE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package unknown_comp_param_value; | ||
|
||
component UnknownParamValue(stream: huh) { | ||
f32 a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "ecsact/runtime/meta.hh" | ||
#include "ecsact/runtime/dynamic.h" | ||
#include "test_lib.hh" | ||
|
||
class StreamComponent : public testing::Test { | ||
public: | ||
ecsact_package_id pkg_id; | ||
|
||
protected: | ||
void SetUp() override { | ||
auto errs = ecsact_interpret_test_files({"stream_component.ecsact"}); | ||
ASSERT_EQ(errs.size(), 0) // | ||
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n"; | ||
pkg_id = ecsact::meta::get_package_ids().at(0); | ||
} | ||
|
||
void TearDown() override { | ||
// ecsact_destroy_package(pkg_id); | ||
} | ||
}; | ||
|
||
TEST_F(StreamComponent, SanityCheck) { | ||
auto comp_id = get_component_by_name(pkg_id, "MyNormieComponent"); | ||
ASSERT_TRUE(comp_id); | ||
|
||
auto comp_like_id = ecsact_meta_component_type( | ||
ecsact_id_cast<ecsact_component_like_id>(*comp_id) | ||
); | ||
|
||
ASSERT_EQ(comp_like_id, ECSACT_COMPONENT_TYPE_NONE); | ||
} | ||
|
||
TEST_F(StreamComponent, HasStreamType) { | ||
auto comp_id = get_component_by_name(pkg_id, "MyStreamComponent"); | ||
ASSERT_TRUE(comp_id); | ||
|
||
auto comp_type = ecsact_meta_component_type( | ||
ecsact_id_cast<ecsact_component_like_id>(*comp_id) | ||
); | ||
|
||
ASSERT_EQ(comp_type, ECSACT_COMPONENT_TYPE_STREAM); | ||
} | ||
|
||
TEST_F(StreamComponent, HasLazyStreamType) { | ||
auto comp_id = get_component_by_name(pkg_id, "MyLazyStreamComponent"); | ||
ASSERT_TRUE(comp_id); | ||
|
||
auto comp_type = ecsact_meta_component_type( | ||
ecsact_id_cast<ecsact_component_like_id>(*comp_id) | ||
); | ||
|
||
ASSERT_EQ(comp_type, ECSACT_COMPONENT_TYPE_LAZY_STREAM); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
main package eval.stream_component; | ||
|
||
component MyStreamComponent(stream) { | ||
f32 a; | ||
} | ||
|
||
component MyLazyStreamComponent(stream: lazy) { | ||
f32 a; | ||
} | ||
|
||
component MyNormieComponent(stream: false) { | ||
f32 a; | ||
} |