Skip to content

Commit d52ba79

Browse files
committed
feat: test that insert_non_send_resource does not send resource
1 parent 80d6273 commit d52ba79

File tree

1 file changed

+22
-0
lines changed
  • crates/bevy_ecs/src/system/commands

1 file changed

+22
-0
lines changed

crates/bevy_ecs/src/system/commands/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,5 +1503,27 @@ mod tests {
15031503

15041504
assert!(!world.contains_non_send::<MyNonSend>());
15051505
}
1506+
1507+
#[test]
1508+
fn is_in_fact_not_being_sent() {
1509+
use std::thread::{self, ThreadId};
1510+
1511+
let mut world = World::default();
1512+
let mut queue = CommandQueue::default();
1513+
1514+
thread::scope(|s| {
1515+
s.spawn(|| {
1516+
let mut commands = Commands::new(&mut queue, &world);
1517+
commands.insert_non_send_resource(|| thread::current().id());
1518+
});
1519+
});
1520+
1521+
queue.apply(&mut world);
1522+
1523+
assert_eq!(
1524+
*world.non_send_resource::<ThreadId>(),
1525+
std::thread::current().id()
1526+
);
1527+
}
15061528
}
15071529
}

0 commit comments

Comments
 (0)