Skip to content

Commit 6bdd741

Browse files
arocullBromeon
authored andcommitted
test: add unit tests for bind and bindv methods to static-method Callables
1 parent 9530704 commit 6bdd741

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

itest/rust/src/builtin_tests/containers/callable_test.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,34 @@ fn callable_static() {
136136

137137
#[cfg(since_api = "4.3")]
138138
assert_eq!(callable.get_argument_count(), 0); // Consistently doesn't work :)
139+
140+
// Test varying binds to static callables
141+
// Last 3 of 4 arguments. Within Godot, bound arguments are used in-order AFTER call arguments
142+
let bindv = callable.bindv(&varray![
143+
"two",
144+
array![&NodePath::from("three/four")],
145+
&RefCounted::new_gd(),
146+
]);
147+
assert!(!Variant::is_nil(&bindv.to_variant()));
148+
// let bindv_result = bindv.callv(&varray![1]); // Call the binding, filling in the first argument
149+
// assert!(!Variant::is_nil(&bindv_result)); // FIXME: Assertion fails
150+
// let bind_result_data: VariantArray = bindv_result.to();
151+
// assert_eq!(4, bind_result_data.len());
152+
153+
#[cfg(since_api = "4.2")]
154+
{
155+
// Same as above, with additional "bind" method
156+
let bind = callable.bind(&[
157+
"two".to_variant(),
158+
array![&NodePath::from("three/four")].to_variant(),
159+
RefCounted::new_gd().to_variant(),
160+
]);
161+
assert!(!Variant::is_nil(&bind.to_variant()));
162+
// let bind_result = bind.call(&[1.to_variant()]);
163+
// assert!(!Variant::is_nil(&bind_result)); // FIXME: Assertion fails
164+
// let bind_result_data: VariantArray = bind_result.to();
165+
// assert_eq!(4, bind_result_data.len());
166+
}
139167
}
140168

141169
#[itest]

0 commit comments

Comments
 (0)