File tree 2 files changed +26
-0
lines changed
crates/bevy_ecs/src/world
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,27 @@ mod tests {
402
402
world. add_archetype_invariant ( ArchetypeInvariant :: < ( A , B , C ) > :: atomic ( ) ) ;
403
403
}
404
404
405
+ #[ test]
406
+ fn on_insert_untyped_happy ( ) {
407
+ let mut world = World :: new ( ) ;
408
+
409
+ world. spawn ( ) . insert_bundle ( ( A , B , C ) ) ;
410
+ let archetype_invariant =
411
+ ArchetypeInvariant :: < ( A , B , C ) > :: atomic ( ) . into_untyped ( & mut world) ;
412
+ world. add_untyped_archetype_invariant ( archetype_invariant) ;
413
+ }
414
+
415
+ #[ test]
416
+ #[ should_panic]
417
+ fn on_insert_untyped_sad ( ) {
418
+ let mut world = World :: new ( ) ;
419
+
420
+ world. spawn ( ) . insert_bundle ( ( A , B ) ) ;
421
+ let archetype_invariant =
422
+ ArchetypeInvariant :: < ( A , B , C ) > :: atomic ( ) . into_untyped ( & mut world) ;
423
+ world. add_untyped_archetype_invariant ( archetype_invariant) ;
424
+ }
425
+
405
426
#[ test]
406
427
fn forbids_happy ( ) {
407
428
let mut world = World :: new ( ) ;
Original file line number Diff line number Diff line change @@ -679,6 +679,11 @@ impl World {
679
679
& mut self ,
680
680
archetype_invariant : UntypedArchetypeInvariant ,
681
681
) {
682
+ for archetype in & self . archetypes . archetypes {
683
+ let components = archetype. components . indices ( ) ;
684
+ archetype_invariant. test_archetype ( components) ;
685
+ }
686
+
682
687
self . archetype_invariants . add ( archetype_invariant) ;
683
688
}
684
689
You can’t perform that action at this time.
0 commit comments