Skip to content

Commit

Permalink
mutate observer unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejiaen committed Oct 31, 2024
1 parent 61511de commit 9ca79c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 62 deletions.
54 changes: 0 additions & 54 deletions crates/bevy_ecs/examples/mutate_obsover.rs

This file was deleted.

24 changes: 24 additions & 0 deletions crates/bevy_ecs/src/storage/entity_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,28 @@ impl EntityChange {
pub fn component(&self) -> ComponentId {
self.component
}
}

mod tests {
use crate::component::ComponentId;
use crate::entity::Entity;
use crate::storage::{Changes, EntityChange};

#[test]
fn changes() {
let mut storage = Changes::new();
let entity = Entity::PLACEHOLDER;
let component = ComponentId::new(1);
storage.push(EntityChange::new(entity, component));
storage.push(EntityChange::new(entity, component));

let changes = storage.take_all();
assert_eq!(changes.len(), 2);
assert_eq!(storage.take_all().len(), 0);

changes.iter().for_each(|change| {
assert_eq!(change.component, component);
assert_eq!(change.entity, entity);
})
}
}
8 changes: 0 additions & 8 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ pub struct World {
pub(crate) command_queue: RawCommandQueue,
}

impl World {

/// Just For Test
pub fn test(&mut self) -> &mut Changes {
&mut self.storages.changes
}
}

impl Default for World {
fn default() -> Self {
let mut world = Self {
Expand Down

0 comments on commit 9ca79c0

Please sign in to comment.