Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vil-mo committed Oct 13, 2024
1 parent 041ed7c commit 504a500
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
5 changes: 3 additions & 2 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,7 @@ unsafe impl<'__w, T: Component> QueryData for Mut<'__w, T> {
/// # use bevy_ecs::prelude::*;
/// # use bevy_ecs::query::QueryData;
/// # use bevy_ecs::query::DataSet;
/// # use bevy_ecs::query::QueryItem;
/// #
/// # #[derive(Component)]
/// # struct Transform;
Expand All @@ -1825,7 +1826,7 @@ unsafe impl<'__w, T: Component> QueryData for Mut<'__w, T> {
/// impl Behavior for Run {
/// type Data = &'static mut Transform;
///
/// fn update(&mut self, data: &mut Transform) {
/// fn update(&mut self, data: &mut QueryItem<'_, Self::Data>) {
/// // Do something...
/// }
/// }
Expand All @@ -1835,7 +1836,7 @@ unsafe impl<'__w, T: Component> QueryData for Mut<'__w, T> {
/// impl Behavior for Jump {
/// type Data = &'static mut Transform;
///
/// fn update(&mut self, data: &mut Transform) {
/// fn update(&mut self, data: &mut QueryItem<'_, Self::Data>) {
/// // Do something different...
/// }
/// }
Expand Down
28 changes: 27 additions & 1 deletion crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ mod tests {
component::{Component, Components, Tick},
entity::{Entities, Entity},
prelude::{AnyOf, EntityRef},
query::{Added, Changed, Or, With, Without},
query::{Added, Changed, Or, With, Without, DataSet},
removal_detection::RemovedComponents,
schedule::{
apply_deferred, common_conditions::resource_exists, Condition, IntoSystemConfigs,
Expand Down Expand Up @@ -810,6 +810,32 @@ mod tests {
run_system(&mut world, sys);
}


#[test]
fn data_set_system() {
fn sys(mut _query: Query<DataSet<(&mut A, &A)>>) {}
let mut world = World::default();
run_system(&mut world, sys);
}

#[test]
#[should_panic]
fn conflicting_query_with_data_set_system() {
fn sys(_query_1: Query<&mut A>, _query_2: Query<DataSet<(&mut A, &B)>>) {}

let mut world = World::default();
run_system(&mut world, sys);
}

#[test]
#[should_panic]
fn conflicting_data_sets_system() {
fn sys(_query_1: Query<DataSet<(&mut A,)>>, _query_2: Query<DataSet<(&mut A, &B)>>) {}

let mut world = World::default();
run_system(&mut world, sys);
}

#[derive(Default, Resource)]
struct BufferRes {
_buffer: Vec<u8>,
Expand Down

0 comments on commit 504a500

Please sign in to comment.