Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemovedComponent removal detection has no tests #2999

Closed
alice-i-cecile opened this issue Oct 21, 2021 · 2 comments
Closed

RemovedComponent removal detection has no tests #2999

alice-i-cecile opened this issue Oct 21, 2021 · 2 comments
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@alice-i-cecile
Copy link
Member

While trying to poke into how this works, and investigate a possible bug, I found that RemovedComponent just has no tests, at all.

The example is nice, but not automated.

We need to verify that removal detection reports the correct entities, and the correct number of entities on both component removal and removal of entities with that particular component.

@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change labels Oct 21, 2021
@hymm
Copy link
Contributor

hymm commented Oct 22, 2021

There is one test here

fn remove_tracking() {
let mut world = World::new();
struct Despawned(Entity);
let a = world.spawn().insert_bundle((W("abc"), W(123))).id();
world.spawn().insert_bundle((W("abc"), W(123)));
world.insert_resource(false);
world.insert_resource(Despawned(a));
world.entity_mut(a).despawn();
fn validate_removed(
removed_i32: RemovedComponents<W<i32>>,
despawned: Res<Despawned>,
mut ran: ResMut<bool>,
) {
assert_eq!(
removed_i32.iter().collect::<Vec<_>>(),
&[despawned.0],
"despawning results in 'removed component' state"
);
*ran = true;
}
run_system(&mut world, validate_removed);
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
}

It tests with despawning an entity. Probably need to add one for removing a component

@alice-i-cecile
Copy link
Member Author

Thanks; I'll add another test quick, improve the docs and make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants