Skip to content

Commit

Permalink
refactor: move world::tests to the corresponding modules
Browse files Browse the repository at this point in the history
  • Loading branch information
SOF3 committed Oct 7, 2023
1 parent 1d344fd commit e70586c
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 200 deletions.
26 changes: 13 additions & 13 deletions codegen/src/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,42 @@ pub(crate) fn imp(input: TokenStream) -> Result<TokenStream> {
}

impl<__Arch: #crate_name::Archetype, #(#field_ty),*>
#crate_name::system::access::IntoZip<__Arch>
#crate_name::system::IntoZip<__Arch>
for #ident<#(#field_ty,)*>
where
#(#field_ty: #crate_name::system::access::IntoZip<__Arch>,)*
#(#field_ty: #crate_name::system::IntoZip<__Arch>,)*
{
type IntoZip = #ident<#(<#field_ty as #crate_name::system::access::IntoZip<__Arch>>::IntoZip,)*>;
type IntoZip = #ident<#(<#field_ty as #crate_name::system::IntoZip<__Arch>>::IntoZip,)*>;

fn into_zip(self) -> Self::IntoZip {
let Self { #(#field_ident,)* } = self;
#ident { #(
#field_ident: <#field_ty as #crate_name::system::access::IntoZip<__Arch>>::into_zip(#field_ident),
#field_ident: <#field_ty as #crate_name::system::IntoZip<__Arch>>::into_zip(#field_ident),
)* }
}
}

impl<__Arch: #crate_name::Archetype, #(#field_ty),*>
#crate_name::system::access::Zip<__Arch>
#crate_name::system::Zip<__Arch>
for #ident<#(#field_ty,)*>
where
#(#field_ty: #crate_name::system::access::Zip<__Arch>,)*
#(#field_ty: #crate_name::system::Zip<__Arch>,)*
{
fn split(&mut self, offset: __Arch::RawEntity) -> Self {
let Self { #(#field_ident,)* } = self;
#ident { #(
#field_ident: <#field_ty as #crate_name::system::access::Zip<__Arch>>::split(#field_ident, offset),
#field_ident: <#field_ty as #crate_name::system::Zip<__Arch>>::split(#field_ident, offset),
)* }
}

type Item = #ident<
#(<#field_ty as #crate_name::system::access::Zip<__Arch>>::Item,)*
#(<#field_ty as #crate_name::system::Zip<__Arch>>::Item,)*
>;
fn get<E: #crate_name::entity::Ref<Archetype = __Arch>>(self, __dynec_entity: E) -> Self::Item {
let Self { #(#field_ident,)* } = self;
let __dynec_entity = #crate_name::entity::TempRef::<__Arch>::new(__dynec_entity.id());
#ident { #(
#field_ident: <#field_ty as #crate_name::system::access::Zip<__Arch>>::get(
#field_ident: <#field_ty as #crate_name::system::Zip<__Arch>>::get(
#field_ident,
__dynec_entity,
),
Expand All @@ -81,18 +81,18 @@ pub(crate) fn imp(input: TokenStream) -> Result<TokenStream> {
}

impl<__Arch: #crate_name::Archetype, #(#field_ty),*>
#crate_name::system::access::ZipChunked<__Arch>
#crate_name::system::ZipChunked<__Arch>
for #ident<#(#field_ty,)*>
where
#(#field_ty: #crate_name::system::access::ZipChunked<__Arch>,)*
#(#field_ty: #crate_name::system::ZipChunked<__Arch>,)*
{
type Chunk = #ident<
#(<#field_ty as #crate_name::system::access::ZipChunked<__Arch>>::Chunk,)*
#(<#field_ty as #crate_name::system::ZipChunked<__Arch>>::Chunk,)*
>;
fn get_chunk(self, __dynec_chunk: #crate_name::entity::TempRefChunk<__Arch>) -> Self::Chunk {
let Self { #(#field_ident,)* } = self;
#ident { #(
#field_ident: <#field_ty as #crate_name::system::access::ZipChunked<__Arch>>::get_chunk(
#field_ident: <#field_ty as #crate_name::system::ZipChunked<__Arch>>::get_chunk(
#field_ident,
__dynec_chunk,
),
Expand Down
9 changes: 6 additions & 3 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ pub use crate::world::rw::isotope::write::partial::WriteIsotopePartial;
pub use crate::world::rw::simple::{ReadSimple, WriteSimple};

pub mod access;
pub use access::{Isotope as AccessIsotope, Single as AccessSingle, Try};
pub use access::{Isotope as AccessIsotope, Single as AccessSingle};

pub mod iter;
pub use iter::{EntityIterator, IntoZip, Try, Zip, ZipChunked};

pub mod partition;
pub use partition::{EntityCreationPartition, Partition};

mod entity;
pub use entity::{EntityCreator, EntityDeleter, EntityIterator};
mod offline_buffer;
pub use offline_buffer::{EntityCreator, EntityDeleter};

pub mod spec;
#[doc(inline)]
Expand Down
3 changes: 0 additions & 3 deletions src/system/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ pub use single::Single;
pub mod isotope;
pub use isotope::Isotope;
pub(crate) use isotope::{PartialStorageMap, StorageMap, StorageMapMut};

mod iter;
pub use iter::{IntoZip, Try, Zip, ZipChunked};
3 changes: 3 additions & 0 deletions src/system/access/isotope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,6 @@ where
storages.map(|storage| AccessSingle::new(storage))
}
}

#[cfg(test)]
mod tests;
12 changes: 2 additions & 10 deletions src/world/tests/isotope.rs → src/system/access/isotope/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ use crate::test_util::*;
use crate::{system, system_test, tracer, world};

fn isotope_discrim_read_test_system(
mut iso1: system::AccessIsotope<
TestArch,
IsoNoInit,
impl system::access::StorageMap<TestArch, IsoNoInit, Key = TestDiscrim1>,
>,
mut iso2: system::AccessIsotope<
TestArch,
IsoWithInit,
impl system::access::StorageMap<TestArch, IsoWithInit, Key = TestDiscrim2>,
>,
mut iso1: impl system::access::isotope::Get<TestArch, IsoNoInit, TestDiscrim1>,
mut iso2: impl system::access::isotope::Get<TestArch, IsoWithInit, TestDiscrim2>,
initials: &InitialEntities,
) {
let ent = initials.strong.as_ref().expect("initials.strong is None");
Expand Down
3 changes: 3 additions & 0 deletions src/system/access/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,6 @@ where
.map(|(entity, data)| (entity::TempRefChunk::new(entity, entity.add(data.len())), data))
}
}

#[cfg(test)]
mod tests;
File renamed without changes.
145 changes: 0 additions & 145 deletions src/system/entity.rs

This file was deleted.

Loading

0 comments on commit e70586c

Please sign in to comment.