@@ -97,6 +97,49 @@ func _ready():
9797 example .group_subgroup_custom_position = Vector2 (50 , 50 )
9898 assert_equal (example .group_subgroup_custom_position , Vector2 (50 , 50 ))
9999
100+ # Test Object::cast_to<>() and that correct wrappers are being used.
101+ var control = Control .new ()
102+ var sprite = Sprite2D .new ()
103+ var example_ref = ExampleRef .new ()
104+
105+ assert_equal (example .test_object_cast_to_node (control ), true )
106+ assert_equal (example .test_object_cast_to_control (control ), true )
107+ assert_equal (example .test_object_cast_to_example (control ), false )
108+
109+ assert_equal (example .test_object_cast_to_node (example ), true )
110+ assert_equal (example .test_object_cast_to_control (example ), true )
111+ assert_equal (example .test_object_cast_to_example (example ), true )
112+
113+ assert_equal (example .test_object_cast_to_node (sprite ), true )
114+ assert_equal (example .test_object_cast_to_control (sprite ), false )
115+ assert_equal (example .test_object_cast_to_example (sprite ), false )
116+
117+ assert_equal (example .test_object_cast_to_node (example_ref ), false )
118+ assert_equal (example .test_object_cast_to_control (example_ref ), false )
119+ assert_equal (example .test_object_cast_to_example (example_ref ), false )
120+
121+ control .queue_free ()
122+ sprite .queue_free ()
123+
124+ # Test conversions to and from Variant.
125+ assert_equal (example .test_variant_vector2i_conversion (Vector2i (1 , 1 )), Vector2i (1 , 1 ))
126+ assert_equal (example .test_variant_vector2i_conversion (Vector2 (1.0 , 1.0 )), Vector2i (1 , 1 ))
127+ assert_equal (example .test_variant_int_conversion (10 ), 10 )
128+ assert_equal (example .test_variant_int_conversion (10.0 ), 10 )
129+ assert_equal (example .test_variant_float_conversion (10.0 ), 10.0 )
130+ assert_equal (example .test_variant_float_conversion (10 ), 10.0 )
131+
132+ # Test that ptrcalls from GDExtension to the engine are correctly encoding Object and RefCounted.
133+ var new_node = Node .new ()
134+ example .test_add_child (new_node )
135+ assert_equal (new_node .get_parent (), example )
136+
137+ var new_tileset = TileSet .new ()
138+ var new_tilemap = TileMap .new ()
139+ example .test_set_tileset (new_tilemap , new_tileset )
140+ assert_equal (new_tilemap .tile_set , new_tileset )
141+ new_tilemap .queue_free ()
142+
100143 # Constants.
101144 assert_equal (Example .FIRST , 0 )
102145 assert_equal (Example .ANSWER_TO_EVERYTHING , 42 )
0 commit comments