Skip to content

Commit

Permalink
fix test for .iter().sort() to include data to sort (#18127)
Browse files Browse the repository at this point in the history
The test case `query_iter_sorts` was doing lots of comparisons to ensure
that various query arrays were sorted, but the arrays were all empty.

This PR spawns some entities so that the entity lists to compare not
empty, and sorting can actually be tested for correctness.
  • Loading branch information
Nathan-Fenner authored Mar 3, 2025
1 parent f42ecc4 commit 755adae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/bevy_ecs/src/query/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2602,10 +2602,16 @@ mod tests {
#[test]
fn query_iter_sorts() {
let mut world = World::new();
for i in 0..100 {
world.spawn(A(i as f32));
world.spawn((A(i as f32), Sparse(i)));
world.spawn(Sparse(i));
}

let mut query = world.query::<Entity>();

let sort = query.iter(&world).sort::<Entity>().collect::<Vec<_>>();
assert_eq!(sort.len(), 300);

let sort_unstable = query
.iter(&world)
Expand Down

0 comments on commit 755adae

Please sign in to comment.