Skip to content

Commit

Permalink
feat: test that insert_non_send_resource does not send resource
Browse files Browse the repository at this point in the history
  • Loading branch information
BD103 committed Apr 1, 2024
1 parent e92a8e9 commit 3938830
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,5 +1503,27 @@ mod tests {

assert!(!world.contains_non_send::<MyNonSend>());
}

#[test]
fn is_in_fact_not_being_sent() {
use std::thread::{self, ThreadId};

let mut world = World::default();
let mut queue = CommandQueue::default();

thread::scope(|s| {
s.spawn(|| {
let mut commands = Commands::new(&mut queue, &world);
commands.insert_non_send_resource(|| thread::current().id());
});
});

queue.apply(&mut world);

assert_eq!(
*world.non_send_resource::<ThreadId>(),
std::thread::current().id()
);
}
}
}

0 comments on commit 3938830

Please sign in to comment.