Skip to content

Commit

Permalink
Add a couple assertions for system types (#10893)
Browse files Browse the repository at this point in the history
# Objective

Test more complex function signatures for exclusive systems, and test
that `StaticSystemParam` is indeed a `SystemParam`.

I mean, it currently works, but might as well add a test for it.
  • Loading branch information
nicopap authored Dec 6, 2023
1 parent 1f97717 commit d2614f2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ mod tests {
},
system::{
Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, Res, ResMut,
Resource, System, SystemState,
Resource, StaticSystemParam, System, SystemState,
},
world::{FromWorld, World},
};
Expand Down Expand Up @@ -1602,14 +1602,29 @@ mod tests {
unimplemented!()
}

fn static_system_param(_: StaticSystemParam<Query<'static, 'static, &W<u32>>>) {
unimplemented!()
}

fn exclusive_with_state(
_: &mut World,
_: Local<bool>,
_: (&mut QueryState<&W<i32>>, &mut SystemState<Query<&W<u32>>>),
_: (),
) {
unimplemented!()
}

fn not(In(val): In<bool>) -> bool {
!val
}

assert_is_system(returning::<Result<u32, std::io::Error>>.map(Result::unwrap));
assert_is_system(returning::<Option<()>>.map(drop));
assert_is_system(returning::<&str>.map(u64::from_str).map(Result::unwrap));
assert_is_system(static_system_param);
assert_is_system(exclusive_in_out::<(), Result<(), std::io::Error>>.map(bevy_utils::error));
assert_is_system(exclusive_with_state);
assert_is_system(returning::<bool>.pipe(exclusive_in_out::<bool, ()>));

returning::<()>.run_if(returning::<bool>.pipe(not));
Expand Down

0 comments on commit d2614f2

Please sign in to comment.