Skip to content

Commit 9ca79c0

Browse files
author
xiejiaen
committed
mutate observer unit test
1 parent 61511de commit 9ca79c0

File tree

3 files changed

+24
-62
lines changed

3 files changed

+24
-62
lines changed

crates/bevy_ecs/examples/mutate_obsover.rs

Lines changed: 0 additions & 54 deletions
This file was deleted.

crates/bevy_ecs/src/storage/entity_change.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,28 @@ impl EntityChange {
5252
pub fn component(&self) -> ComponentId {
5353
self.component
5454
}
55+
}
56+
57+
mod tests {
58+
use crate::component::ComponentId;
59+
use crate::entity::Entity;
60+
use crate::storage::{Changes, EntityChange};
61+
62+
#[test]
63+
fn changes() {
64+
let mut storage = Changes::new();
65+
let entity = Entity::PLACEHOLDER;
66+
let component = ComponentId::new(1);
67+
storage.push(EntityChange::new(entity, component));
68+
storage.push(EntityChange::new(entity, component));
69+
70+
let changes = storage.take_all();
71+
assert_eq!(changes.len(), 2);
72+
assert_eq!(storage.take_all().len(), 0);
73+
74+
changes.iter().for_each(|change| {
75+
assert_eq!(change.component, component);
76+
assert_eq!(change.entity, entity);
77+
})
78+
}
5579
}

crates/bevy_ecs/src/world/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ pub struct World {
136136
pub(crate) command_queue: RawCommandQueue,
137137
}
138138

139-
impl World {
140-
141-
/// Just For Test
142-
pub fn test(&mut self) -> &mut Changes {
143-
&mut self.storages.changes
144-
}
145-
}
146-
147139
impl Default for World {
148140
fn default() -> Self {
149141
let mut world = Self {

0 commit comments

Comments
 (0)