Move /src/test to /tests
This commit is contained in:
parent
ca855e6e42
commit
cf2dff2b1e
27592 changed files with 0 additions and 0 deletions
23
tests/ui/threads-sendsync/task-spawn-move-and-copy.rs
Normal file
23
tests/ui/threads-sendsync/task-spawn-move-and-copy.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// run-pass
|
||||
#![allow(unused_must_use)]
|
||||
// ignore-emscripten no threads support
|
||||
|
||||
use std::thread;
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel::<usize>();
|
||||
|
||||
let x: Box<isize> = Box::new(1);
|
||||
let x_in_parent = &(*x) as *const isize as usize;
|
||||
|
||||
let t = thread::spawn(move || {
|
||||
let x_in_child = &(*x) as *const isize as usize;
|
||||
tx.send(x_in_child).unwrap();
|
||||
});
|
||||
|
||||
let x_in_child = rx.recv().unwrap();
|
||||
assert_eq!(x_in_parent, x_in_child);
|
||||
|
||||
t.join();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue