Skip to content

Commit 66db6df

Browse files
author
xiejiaen
committed
mutate observer unit test
1 parent 61511de commit 66db6df

File tree

3 files changed

+25
-63
lines changed

3 files changed

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

crates/bevy_ecs/src/world/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ use bevy_ptr::UnsafeCellDeref;
6363

6464
use core::panic::Location;
6565
use unsafe_world_cell::{UnsafeEntityCell, UnsafeWorldCell};
66-
use crate::storage::Changes;
6766

6867
/// A [`World`] mutation.
6968
///
@@ -136,14 +135,6 @@ pub struct World {
136135
pub(crate) command_queue: RawCommandQueue,
137136
}
138137

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

0 commit comments

Comments
 (0)