File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -570,6 +570,18 @@ fn array_resize() {
570
570
assert_eq ! ( a, Array :: new( ) ) ;
571
571
}
572
572
573
+ // Tests that arrays of objects can be declared without explicit type annotations. A similar test exists for DynGd in dyn_gd_test.rs.
574
+ // This has deliberately been added to guard against regressions in case `AsArg` is extended (T: Inherits<Base> support broke this).
575
+ fn __array_type_inference ( ) {
576
+ let a = Node :: new_alloc ( ) ;
577
+ let b = Node :: new_alloc ( ) ;
578
+ let _array = array ! [ & a, & b] ;
579
+
580
+ let c = ArrayTest :: new_gd ( ) ;
581
+ let d = ArrayTest :: new_gd ( ) ;
582
+ let _array = array ! [ & c, & d] ;
583
+ }
584
+
573
585
#[ derive( GodotClass , Debug ) ]
574
586
#[ class( init, base=RefCounted ) ]
575
587
struct ArrayTest ;
Original file line number Diff line number Diff line change 4
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
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} ;
8
9
// Test that all important dyn-related symbols are in the prelude.
9
10
use godot:: prelude:: * ;
@@ -352,6 +353,11 @@ fn dyn_gd_store_in_godot_array() {
352
353
assert_eq ! ( array. at( 1 ) . dyn_bind( ) . get_hitpoints( ) , 100 ) ;
353
354
354
355
array. at ( 1 ) . free ( ) ;
356
+
357
+ // Tests also type inference of array![]. Independent variable c.
358
+ let c = Gd :: from_object ( RefcHealth { hp : 33 } ) . into_dyn ( ) ;
359
+ let array_inferred = array ! [ & c] ;
360
+ assert_eq ! ( array_inferred. at( 0 ) . dyn_bind( ) . get_hitpoints( ) , 33 ) ;
355
361
}
356
362
357
363
#[ itest]
You can’t perform that action at this time.
0 commit comments