Skip to content

Commit

Permalink
Test that attempting to delete an entity with the wrong generation do…
Browse files Browse the repository at this point in the history
…esn't clear components
  • Loading branch information
Imberflur committed Jun 6, 2023
1 parent 81073f3 commit 7b03fca
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,35 @@ fn task_panics() {
.dispatch(&mut world);
}

#[test]
fn delete_wrong_gen() {
let mut world = create_world();

// create
let entity_a = world.create_entity().with(CompInt(7)).build();
assert_eq!(
world.read_component::<CompInt>().get(entity_a),
Some(&CompInt(7))
);
// delete
assert!(world.delete_entity(entity_a).is_ok());
assert_eq!(world.read_component::<CompInt>().get(entity_a), None);
// create
let entity_b = world.create_entity().with(CompInt(6)).build();
assert_eq!(
world.read_component::<CompInt>().get(entity_b),
Some(&CompInt(6))
);
assert_eq!(world.read_component::<CompInt>().get(entity_a), None);
// delete stale
assert!(world.delete_entity(entity_a).is_err());
assert_eq!(
world.read_component::<CompInt>().get(entity_b),
Some(&CompInt(6))
);
assert_eq!(world.read_component::<CompInt>().get(entity_a), None);
}

#[test]
fn dynamic_create() {
struct Sys;
Expand Down

0 comments on commit 7b03fca

Please sign in to comment.