@@ -1475,11 +1475,14 @@ unsafe impl<S: SystemParamState, P: SystemParam + 'static> SystemParamState
1475
1475
1476
1476
#[ cfg( test) ]
1477
1477
mod tests {
1478
+ use std:: marker:: PhantomData ;
1479
+
1478
1480
use super :: SystemParam ;
1479
1481
use crate :: {
1480
1482
self as bevy_ecs, // Necessary for the `SystemParam` Derive when used inside `bevy_ecs`.
1481
1483
query:: WorldQuery ,
1482
- system:: Query ,
1484
+ schedule:: SystemLabel ,
1485
+ system:: { ParamSet , Query } ,
1483
1486
} ;
1484
1487
1485
1488
// Compile test for #2838
@@ -1492,4 +1495,65 @@ mod tests {
1492
1495
> {
1493
1496
_query : Query < ' w , ' s , Q , F > ,
1494
1497
}
1498
+
1499
+ //
1500
+ // Test auto-labels with the `SystemParam` derive
1501
+
1502
+ #[ derive( SystemLabel ) ]
1503
+ struct LabelA ;
1504
+ #[ derive( SystemLabel ) ]
1505
+ struct LabelB ;
1506
+
1507
+ #[ derive( SystemParam , Default ) ]
1508
+ #[ system_param( label = LabelA ) ]
1509
+ struct A < ' w , ' s > {
1510
+ #[ system_param( ignore) ]
1511
+ _marker : PhantomData < Query < ' w , ' s , ( ) > > ,
1512
+ }
1513
+ #[ derive( SystemParam ) ]
1514
+ #[ system_param( label = LabelB ) ]
1515
+ struct B < ' w , ' s > {
1516
+ #[ system_param( ignore) ]
1517
+ _marker : PhantomData < Query < ' w , ' s , ( ) > > ,
1518
+ }
1519
+
1520
+ #[ test]
1521
+ fn test_auto_labels ( ) {
1522
+ let a_labels = A :: auto_labels ( ) ;
1523
+ assert ! ( a_labels. contains( & LabelA . as_label( ) ) ) ;
1524
+
1525
+ let b_labels = B :: auto_labels ( ) ;
1526
+ assert ! ( b_labels. contains( & LabelB . as_label( ) ) ) ;
1527
+ }
1528
+
1529
+ #[ derive( SystemParam ) ]
1530
+ struct Ab < ' w , ' s > {
1531
+ _a : A < ' w , ' s > ,
1532
+ _b : B < ' w , ' s > ,
1533
+ }
1534
+
1535
+ #[ test]
1536
+ fn test_auto_labels_derive ( ) {
1537
+ let ab_labels = Ab :: auto_labels ( ) ;
1538
+ assert ! ( ab_labels. contains( & LabelA . as_label( ) ) ) ;
1539
+ assert ! ( ab_labels. contains( & LabelB . as_label( ) ) ) ;
1540
+ }
1541
+
1542
+ // Test auto-labels in paramsets
1543
+
1544
+ #[ test]
1545
+ fn test_auto_labels_paramset ( ) {
1546
+ let set_labels = ParamSet :: < ( A , B ) > :: auto_labels ( ) ;
1547
+ assert ! ( set_labels. contains( & LabelA . as_label( ) ) ) ;
1548
+ assert ! ( set_labels. contains( & LabelB . as_label( ) ) ) ;
1549
+ }
1550
+
1551
+ // Test auto-labels in tuples
1552
+
1553
+ #[ test]
1554
+ fn test_auto_labels_tuple ( ) {
1555
+ let tup_labels = <( A , B ) >:: auto_labels ( ) ;
1556
+ assert ! ( tup_labels. contains( & LabelA . as_label( ) ) ) ;
1557
+ assert ! ( tup_labels. contains( & LabelB . as_label( ) ) ) ;
1558
+ }
1495
1559
}
0 commit comments