improved the entity_index_map unit test (#19936)
...which previously used a HashSet, whos iter has no ordering guarantee fixes #19687 i also discovered that the asserted order in the unit test is reversed, so i fixed that. I dont know if that reversed order is intentional Edit: i referenced the wrong issue oops
This commit is contained in:
parent
4e32caf027
commit
4564a5ba0d
@ -687,19 +687,22 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn entity_index_map() {
|
||||
for add_before in [false, true] {
|
||||
#[derive(Component)]
|
||||
#[relationship(relationship_target = RelTarget)]
|
||||
struct Rel(Entity);
|
||||
|
||||
#[derive(Component)]
|
||||
#[relationship_target(relationship = Rel, linked_spawn)]
|
||||
struct RelTarget(EntityHashSet);
|
||||
struct RelTarget(Vec<Entity>);
|
||||
|
||||
let mut world = World::new();
|
||||
if add_before {
|
||||
let _ = world.spawn_empty().id();
|
||||
}
|
||||
let a = world.spawn_empty().id();
|
||||
let b = world.spawn_empty().id();
|
||||
let c = world.spawn_empty().id();
|
||||
|
||||
let d = world.spawn_empty().id();
|
||||
|
||||
world.entity_mut(a).add_related::<Rel>(&[b, c, d]);
|
||||
@ -708,7 +711,7 @@ mod tests {
|
||||
let collection = rel_target.collection();
|
||||
|
||||
// Insertions should maintain ordering
|
||||
assert!(collection.iter().eq(&[d, c, b]));
|
||||
assert!(collection.iter().eq([b, c, d]));
|
||||
|
||||
world.entity_mut(c).despawn();
|
||||
|
||||
@ -716,7 +719,8 @@ mod tests {
|
||||
let collection = rel_target.collection();
|
||||
|
||||
// Removals should maintain ordering
|
||||
assert!(collection.iter().eq(&[d, b]));
|
||||
assert!(collection.iter().eq([b, d]));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user