Skip to content

Commit 1dfe871

Browse files
committed
Test required params/returns (currently UB)
1 parent e430cce commit 1dfe871

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

itest/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ crate-type = ["cdylib"]
1313
# Default feature MUST be empty for workflow reasons, even if it differs from the default feature set in upstream `godot` crate.
1414
default = []
1515
codegen-full = ["godot/__codegen-full"]
16-
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api"]
16+
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api", "godot/experimental-required-objs"]
1717
experimental-threads = ["godot/experimental-threads"]
1818
register-docs = ["godot/register-docs"]
1919
serde = ["dep:serde", "dep:serde_json", "godot/serde"]

itest/rust/src/engine_tests/node_test.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,25 @@ fn node_call_group(ctx: &TestContext) {
7474
tree.call_group("group", "remove_meta", vslice!["something"]);
7575
assert!(!node.has_meta("something"));
7676
}
77+
78+
// Experimental required parameter/return value: https://github.com/godot-rust/gdext/pull/1383.
79+
#[cfg(all(feature = "codegen-full-experimental"))]
80+
#[itest(focus)]
81+
fn node_required_param_return() {
82+
use godot::classes::Tween;
83+
use godot::obj::Gd;
84+
85+
let mut parent = Node::new_alloc();
86+
let child = Node::new_alloc();
87+
88+
// add_child() takes required arg, so this still works.
89+
// (Test for Option *not* working anymore is in godot > no_compile_tests.)
90+
parent.add_child(&child);
91+
92+
// create_tween() returns now non-null instance.
93+
let tween: Gd<Tween> = parent.create_tween();
94+
assert!(tween.is_instance_valid());
95+
assert!(tween.to_string().contains("Tween"));
96+
97+
parent.free();
98+
}

0 commit comments

Comments
 (0)