|
5 | 5 | * file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
6 | 6 | */
|
7 | 7 |
|
| 8 | +use crate::framework::{expect_panic, itest, runs_release}; |
| 9 | +use crate::object_tests::object_test::ObjPayload; |
8 | 10 | use godot::builtin::{Variant, Vector3};
|
9 | 11 | use godot::classes::{Node, Node3D, Object};
|
| 12 | +use godot::init::GdextBuild; |
10 | 13 | use godot::meta::error::CallError;
|
11 | 14 | use godot::meta::{FromGodot, ToGodot};
|
12 | 15 | use godot::obj::{InstanceId, NewAlloc};
|
13 | 16 | use std::error::Error;
|
14 | 17 | use std::sync::{Arc, Mutex};
|
15 | 18 |
|
16 |
| -use crate::framework::{expect_panic, itest, runs_release}; |
17 |
| -use crate::object_tests::object_test::ObjPayload; |
18 |
| - |
19 | 19 | #[itest]
|
20 | 20 | fn dynamic_call_no_args() {
|
21 | 21 | let mut node = Node3D::new_alloc().upcast::<Object>();
|
@@ -288,14 +288,22 @@ fn dynamic_call_parameter_mismatch_engine() {
|
288 | 288 | .try_call("set_name", &[123.to_variant()])
|
289 | 289 | .expect_err("expected failed call");
|
290 | 290 |
|
| 291 | + // Node::set_name() changed to accept StringName, in https://github.com/godotengine/godot/pull/76560. |
| 292 | + // Needs to check the runtime version rather than API version, because reflection calls always latest method (no compatibility method). |
| 293 | + let target_type = if GdextBuild::before_api("4.5") { |
| 294 | + "STRING" |
| 295 | + } else { |
| 296 | + "STRING_NAME" |
| 297 | + }; |
| 298 | + let expected_error = format!( |
| 299 | + "godot-rust function call failed: Object::call(&\"set_name\", [va] 123)\ |
| 300 | + \n Reason: parameter #1 -- cannot convert from INT to {target_type}" |
| 301 | + ); |
| 302 | + |
291 | 303 | // Note: currently no mention of Node::set_name(). Not sure if easily possible to add.
|
292 | 304 | assert_eq!(call_error.class_name(), Some("Object"));
|
293 | 305 | assert_eq!(call_error.method_name(), "call");
|
294 |
| - assert_eq!( |
295 |
| - call_error.to_string(), |
296 |
| - "godot-rust function call failed: Object::call(&\"set_name\", [va] 123)\ |
297 |
| - \n Reason: parameter #1 -- cannot convert from INT to STRING" |
298 |
| - ); |
| 306 | + assert_eq!(call_error.to_string(), expected_error); |
299 | 307 |
|
300 | 308 | node.free();
|
301 | 309 | }
|
|
0 commit comments