@@ -537,15 +537,11 @@ pub(super) fn enforce_no_required_components_recursion(
537
537
538
538
#[ cfg( test) ]
539
539
mod tests {
540
- use std:: {
541
- string:: { String , ToString } ,
542
- vec,
543
- vec:: Vec ,
544
- } ;
540
+ use std:: string:: { String , ToString } ;
545
541
546
542
use crate :: {
547
543
bundle:: Bundle ,
548
- component:: { Component , ComponentId , RequiredComponents , RequiredComponentsError } ,
544
+ component:: { Component , RequiredComponentsError } ,
549
545
prelude:: Resource ,
550
546
world:: World ,
551
547
} ;
@@ -1194,90 +1190,7 @@ mod tests {
1194
1190
}
1195
1191
1196
1192
#[ test]
1197
- fn required_components_inheritance_depth ( ) {
1198
- // Test that inheritance depths are computed correctly for requirements.
1199
- //
1200
- // Requirements with `require` attribute:
1201
- //
1202
- // A -> B -> C
1203
- // 0 1
1204
- //
1205
- // Runtime requirements:
1206
- //
1207
- // X -> A -> B -> C
1208
- // 0 1 2
1209
- //
1210
- // X -> Y -> Z -> B -> C
1211
- // 0 1 2 3
1212
-
1213
- #[ derive( Component , Default ) ]
1214
- #[ require( B ) ]
1215
- struct A ;
1216
-
1217
- #[ derive( Component , Default ) ]
1218
- #[ require( C ) ]
1219
- struct B ;
1220
-
1221
- #[ derive( Component , Default ) ]
1222
- struct C ;
1223
-
1224
- #[ derive( Component , Default ) ]
1225
- struct X ;
1226
-
1227
- #[ derive( Component , Default ) ]
1228
- struct Y ;
1229
-
1230
- #[ derive( Component , Default ) ]
1231
- struct Z ;
1232
-
1233
- let mut world = World :: new ( ) ;
1234
-
1235
- let a = world. register_component :: < A > ( ) ;
1236
- let b = world. register_component :: < B > ( ) ;
1237
- let c = world. register_component :: < C > ( ) ;
1238
- let y = world. register_component :: < Y > ( ) ;
1239
- let z = world. register_component :: < Z > ( ) ;
1240
-
1241
- world. register_required_components :: < X , A > ( ) ;
1242
- world. register_required_components :: < X , Y > ( ) ;
1243
- world. register_required_components :: < Y , Z > ( ) ;
1244
- world. register_required_components :: < Z , B > ( ) ;
1245
-
1246
- world. spawn ( X ) ;
1247
-
1248
- let required_a = world. get_required_components :: < A > ( ) . unwrap ( ) ;
1249
- let required_b = world. get_required_components :: < B > ( ) . unwrap ( ) ;
1250
- let required_c = world. get_required_components :: < C > ( ) . unwrap ( ) ;
1251
- let required_x = world. get_required_components :: < X > ( ) . unwrap ( ) ;
1252
- let required_y = world. get_required_components :: < Y > ( ) . unwrap ( ) ;
1253
- let required_z = world. get_required_components :: < Z > ( ) . unwrap ( ) ;
1254
-
1255
- /// Returns the component IDs and inheritance depths of the required components
1256
- /// in ascending order based on the component ID.
1257
- fn to_vec ( required : & RequiredComponents ) -> Vec < ( ComponentId , u16 ) > {
1258
- let mut vec = required
1259
- . 0
1260
- . iter ( )
1261
- . map ( |( id, component) | ( * id, component. inheritance_depth ) )
1262
- . collect :: < Vec < _ > > ( ) ;
1263
- vec. sort_by_key ( |( id, _) | * id) ;
1264
- vec
1265
- }
1266
-
1267
- // Check that the inheritance depths are correct for each component.
1268
- assert_eq ! ( to_vec( required_a) , vec![ ( b, 0 ) , ( c, 1 ) ] ) ;
1269
- assert_eq ! ( to_vec( required_b) , vec![ ( c, 0 ) ] ) ;
1270
- assert_eq ! ( to_vec( required_c) , vec![ ] ) ;
1271
- assert_eq ! (
1272
- to_vec( required_x) ,
1273
- vec![ ( a, 0 ) , ( b, 1 ) , ( c, 2 ) , ( y, 0 ) , ( z, 1 ) ]
1274
- ) ;
1275
- assert_eq ! ( to_vec( required_y) , vec![ ( b, 1 ) , ( c, 2 ) , ( z, 0 ) ] ) ;
1276
- assert_eq ! ( to_vec( required_z) , vec![ ( b, 0 ) , ( c, 1 ) ] ) ;
1277
- }
1278
-
1279
- #[ test]
1280
- fn required_components_inheritance_depth_bias ( ) {
1193
+ fn required_components_bundle_priority ( ) {
1281
1194
#[ derive( Component , PartialEq , Eq , Clone , Copy , Debug ) ]
1282
1195
struct MyRequired ( bool ) ;
1283
1196
@@ -1303,7 +1216,7 @@ mod tests {
1303
1216
. get :: < MyRequired > ( )
1304
1217
. cloned ( ) ;
1305
1218
1306
- assert_eq ! ( order_a, Some ( MyRequired ( true ) ) ) ;
1219
+ assert_eq ! ( order_a, Some ( MyRequired ( false ) ) ) ;
1307
1220
assert_eq ! ( order_b, Some ( MyRequired ( true ) ) ) ;
1308
1221
}
1309
1222
0 commit comments