Skip to content

Commit 4f90a92

Browse files
committed
Test to verify that virtual functions declare Option<Gd<T>> (unless
specified otherwise)
1 parent e217531 commit 4f90a92

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

itest/rust/src/object_tests/object_test.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,11 +1057,3 @@ fn double_use_reference() {
10571057
double_use.free();
10581058
emitter.free();
10591059
}
1060-
1061-
// ----------------------------------------------------------------------------------------------------------------------------------------------
1062-
1063-
// There isn't a good way to test editor plugins, but we can at least declare one to ensure that the macro
1064-
// compiles.
1065-
#[derive(GodotClass)]
1066-
#[class(no_init, base = EditorPlugin, editor_plugin, tool)]
1067-
struct CustomEditorPlugin;

itest/rust/src/object_tests/virtual_methods_test.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use godot::classes::resource_loader::CacheMode;
1919
#[cfg(feature = "codegen-full")]
2020
use godot::classes::Material;
2121
use godot::classes::{
22-
BoxMesh, INode, INode2D, IPrimitiveMesh, IRefCounted, IResourceFormatLoader, IRigidBody2D,
23-
InputEvent, InputEventAction, Node, Node2D, PrimitiveMesh, RefCounted, ResourceFormatLoader,
24-
ResourceLoader, Viewport, Window,
22+
BoxMesh, IEditorPlugin, INode, INode2D, IPrimitiveMesh, IRefCounted, IResourceFormatLoader,
23+
IRigidBody2D, InputEvent, InputEventAction, Node, Node2D, Object, PrimitiveMesh, RefCounted,
24+
ResourceFormatLoader, ResourceLoader, Viewport, Window,
2525
};
2626
use godot::meta::ToGodot;
2727
use godot::obj::{Base, Gd, NewAlloc, NewGd};
@@ -773,3 +773,25 @@ impl GetSetTest {
773773
self.always_get_100
774774
}
775775
}
776+
777+
// ----------------------------------------------------------------------------------------------------------------------------------------------
778+
779+
// There isn't a good way to test editor plugins, but we can at least declare one to ensure that the macro
780+
// compiles.
781+
#[derive(GodotClass)]
782+
#[class(no_init, base = EditorPlugin, editor_plugin, tool)]
783+
struct CustomEditorPlugin;
784+
785+
// Just override EditorPlugin::edit() to verify method is declared with Option<T>.
786+
// See https://github.com/godot-rust/gdext/issues/494.
787+
#[godot_api]
788+
impl IEditorPlugin for CustomEditorPlugin {
789+
fn edit(&mut self, _object: Option<Gd<Object>>) {
790+
// Do nothing.
791+
}
792+
793+
// This parameter is non-null.
794+
fn handles(&self, _object: Gd<Object>) -> bool {
795+
true
796+
}
797+
}

0 commit comments

Comments
 (0)