Skip to content

Commit

Permalink
Derive Var and Export for DynGd<T, D>
Browse files Browse the repository at this point in the history
- Fix tests (make sure that all instances will be properly freed), move wrong type test to one that contains nothing but RefCounted instances
  • Loading branch information
Yarwin committed Jan 6, 2025
1 parent d46b865 commit 07772e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion itest/godot/ManualFfiTests.gd
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,17 @@ func test_export_dyn_gd():
var refc = RefcHealth.new()
dyn_gd_exporter.first = refc
assert_eq(dyn_gd_exporter.first, refc)
dyn_gd_exporter.free()
node.free()

func test_export_dyn_gd_should_fail_for_wrong_type():
var dyn_gd_exporter = RcDynGdExporter.new()
var refc = RefcHealth.new()
disable_error_messages()
dyn_gd_exporter.second = refc # Should fail.
enable_error_messages()
assert_fail("DynGdExporter.second should only accept NodeHealth if it implements InstanceIdProvider trait")


class MockObjGd extends Object:
var i: int = 0

Expand Down
7 changes: 7 additions & 0 deletions itest/rust/src/object_tests/dyn_gd_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ impl InstanceIdProvider for foreign::NodeHealth {
// ----------------------------------------------------------------------------------------------------------------------------------------------
// Check if DynGd can be properly exported

#[derive(GodotClass)]
#[class(init)]
struct RcDynGdExporter {
#[var]
only_node_health: Option<DynGd<foreign::NodeHealth, dyn InstanceIdProvider>>,
}

#[derive(GodotClass)]
#[class(base=Node)]
struct DynGdExporter {
Expand Down

0 comments on commit 07772e9

Please sign in to comment.