diff options
Diffstat (limited to 'src/libstd/comm/mod.rs')
| -rw-r--r-- | src/libstd/comm/mod.rs | 376 |
1 files changed, 188 insertions, 188 deletions
diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 72ddbe19f54..29a7b0dd0cc 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -136,7 +136,7 @@ //! select! { //! val = rx.recv() => println!("Received {}", val), //! () = timeout.recv() => { -//! println!("timed out, total time was more than 10 seconds") +//! println!("timed out, total time was more than 10 seconds"); //! break; //! } //! } @@ -160,7 +160,7 @@ //! select! { //! val = rx.recv() => println!("Received {}", val), //! () = timeout.recv() => { -//! println!("timed out, no message received in 5 seconds") +//! println!("timed out, no message received in 5 seconds"); //! break; //! } //! } @@ -331,7 +331,7 @@ use rustrt::task::BlockedTask; pub use comm::select::{Select, Handle}; -macro_rules! test ( +macro_rules! test { { fn $name:ident() $b:block $(#[$a:meta])*} => ( mod $name { #![allow(unused_imports)] @@ -347,7 +347,7 @@ macro_rules! test ( $(#[$a])* #[test] fn f() { $b } } ) -) +} mod oneshot; mod select; @@ -1036,70 +1036,70 @@ mod test { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = channel::<int>(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn drop_full() { + test! { fn drop_full() { let (tx, _rx) = channel(); tx.send(box 1i); - }) + } } - test!(fn drop_full_shared() { + test! { fn drop_full_shared() { let (tx, _rx) = channel(); drop(tx.clone()); drop(tx.clone()); tx.send(box 1i); - }) + } } - test!(fn smoke_shared() { + test! { fn smoke_shared() { let (tx, rx) = channel::<int>(); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_threads() { + test! { fn smoke_threads() { let (tx, rx) = channel::<int>(); spawn(move|| { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = channel::<int>(); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone() { + test! { fn smoke_shared_port_gone() { let (tx, rx) = channel::<int>(); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone2() { + test! { fn smoke_shared_port_gone2() { let (tx, rx) = channel::<int>(); drop(rx); let tx2 = tx.clone(); drop(tx); tx2.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent() { + test! { fn port_gone_concurrent() { let (tx, rx) = channel::<int>(); spawn(move|| { rx.recv(); }); loop { tx.send(1) } - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent_shared() { + test! { fn port_gone_concurrent_shared() { let (tx, rx) = channel::<int>(); let tx2 = tx.clone(); spawn(move|| { @@ -1109,32 +1109,32 @@ mod test { tx.send(1); tx2.send(1); } - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone() { + test! { fn smoke_chan_gone() { let (tx, rx) = channel::<int>(); drop(tx); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone_shared() { + test! { fn smoke_chan_gone_shared() { let (tx, rx) = channel::<()>(); let tx2 = tx.clone(); drop(tx); drop(tx2); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn chan_gone_concurrent() { + test! { fn chan_gone_concurrent() { let (tx, rx) = channel::<int>(); spawn(move|| { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = channel::<int>(); spawn(move|| { for _ in range(0u, 10000) { tx.send(1i); } @@ -1142,9 +1142,9 @@ mod test { for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } - }) + } } - test!(fn stress_shared() { + test! { fn stress_shared() { static AMT: uint = 10000; static NTHREADS: uint = 8; let (tx, rx) = channel::<int>(); @@ -1169,7 +1169,7 @@ mod test { } drop(tx); drx.recv(); - }) + } } #[test] fn send_from_outside_runtime() { @@ -1231,26 +1231,26 @@ mod test { rx3.recv(); } - test!(fn oneshot_single_thread_close_port_first() { + test! { fn oneshot_single_thread_close_port_first() { // Simple test of closing without sending let (_tx, rx) = channel::<int>(); drop(rx); - }) + } } - test!(fn oneshot_single_thread_close_chan_first() { + test! { fn oneshot_single_thread_close_chan_first() { // Simple test of closing without sending let (tx, _rx) = channel::<int>(); drop(tx); - }) + } } - test!(fn oneshot_single_thread_send_port_close() { + test! { fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = channel::<Box<int>>(); drop(rx); tx.send(box 0); - } #[should_fail]) + } #[should_fail] } - test!(fn oneshot_single_thread_recv_chan_close() { + test! { fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = task::try(move|| { let (tx, rx) = channel::<int>(); @@ -1259,67 +1259,67 @@ mod test { }); // What is our res? assert!(res.is_err()); - }) + } } - test!(fn oneshot_single_thread_send_then_recv() { + test! { fn oneshot_single_thread_send_then_recv() { let (tx, rx) = channel::<Box<int>>(); tx.send(box 10); assert!(rx.recv() == box 10); - }) + } } - test!(fn oneshot_single_thread_try_send_open() { + test! { fn oneshot_single_thread_try_send_open() { let (tx, rx) = channel::<int>(); assert!(tx.send_opt(10).is_ok()); assert!(rx.recv() == 10); - }) + } } - test!(fn oneshot_single_thread_try_send_closed() { + test! { fn oneshot_single_thread_try_send_closed() { let (tx, rx) = channel::<int>(); drop(rx); assert!(tx.send_opt(10).is_err()); - }) + } } - test!(fn oneshot_single_thread_try_recv_open() { + test! { fn oneshot_single_thread_try_recv_open() { let (tx, rx) = channel::<int>(); tx.send(10); assert!(rx.recv_opt() == Ok(10)); - }) + } } - test!(fn oneshot_single_thread_try_recv_closed() { + test! { fn oneshot_single_thread_try_recv_closed() { let (tx, rx) = channel::<int>(); drop(tx); assert!(rx.recv_opt() == Err(())); - }) + } } - test!(fn oneshot_single_thread_peek_data() { + test! { fn oneshot_single_thread_peek_data() { let (tx, rx) = channel::<int>(); - assert_eq!(rx.try_recv(), Err(Empty)) + assert_eq!(rx.try_recv(), Err(Empty)); tx.send(10); assert_eq!(rx.try_recv(), Ok(10)); - }) + } } - test!(fn oneshot_single_thread_peek_close() { + test! { fn oneshot_single_thread_peek_close() { let (tx, rx) = channel::<int>(); drop(tx); assert_eq!(rx.try_recv(), Err(Disconnected)); assert_eq!(rx.try_recv(), Err(Disconnected)); - }) + } } - test!(fn oneshot_single_thread_peek_open() { + test! { fn oneshot_single_thread_peek_open() { let (_tx, rx) = channel::<int>(); assert_eq!(rx.try_recv(), Err(Empty)); - }) + } } - test!(fn oneshot_multi_task_recv_then_send() { + test! { fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::<Box<int>>(); spawn(move|| { assert!(rx.recv() == box 10); }); tx.send(box 10); - }) + } } - test!(fn oneshot_multi_task_recv_then_close() { + test! { fn oneshot_multi_task_recv_then_close() { let (tx, rx) = channel::<Box<int>>(); spawn(move|| { drop(tx); @@ -1328,9 +1328,9 @@ mod test { assert!(rx.recv() == box 10); }); assert!(res.is_err()); - }) + } } - test!(fn oneshot_multi_thread_close_stress() { + test! { fn oneshot_multi_thread_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1338,9 +1338,9 @@ mod test { }); drop(tx); } - }) + } } - test!(fn oneshot_multi_thread_send_close_stress() { + test! { fn oneshot_multi_thread_send_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1350,9 +1350,9 @@ mod test { tx.send(1); }); } - }) + } } - test!(fn oneshot_multi_thread_recv_close_stress() { + test! { fn oneshot_multi_thread_recv_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1367,9 +1367,9 @@ mod test { }); }); } - }) + } } - test!(fn oneshot_multi_thread_send_recv_stress() { + test! { fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); spawn(move|| { @@ -1379,9 +1379,9 @@ mod test { assert!(rx.recv() == box 10i); }); } - }) + } } - test!(fn stream_send_recv_stress() { + test! { fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); @@ -1406,16 +1406,16 @@ mod test { }); } } - }) + } } - test!(fn recv_a_lot() { + test! { fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = channel(); for _ in range(0i, 10000) { tx.send(()); } for _ in range(0i, 10000) { rx.recv(); } - }) + } } - test!(fn shared_chan_stress() { + test! { fn shared_chan_stress() { let (tx, rx) = channel(); let total = stress_factor() + 100; for _ in range(0, total) { @@ -1428,9 +1428,9 @@ mod test { for _ in range(0, total) { rx.recv(); } - }) + } } - test!(fn test_nested_recv_iter() { + test! { fn test_nested_recv_iter() { let (tx, rx) = channel::<int>(); let (total_tx, total_rx) = channel::<int>(); @@ -1447,9 +1447,9 @@ mod test { tx.send(2); drop(tx); assert_eq!(total_rx.recv(), 6); - }) + } } - test!(fn test_recv_iter_break() { + test! { fn test_recv_iter_break() { let (tx, rx) = channel::<int>(); let (count_tx, count_rx) = channel(); @@ -1471,9 +1471,9 @@ mod test { let _ = tx.send_opt(2); drop(tx); assert_eq!(count_rx.recv(), 4); - }) + } } - test!(fn try_recv_states() { + test! { fn try_recv_states() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<()>(); let (tx3, rx3) = channel::<()>(); @@ -1494,11 +1494,11 @@ mod test { tx2.send(()); rx3.recv(); assert_eq!(rx1.try_recv(), Err(Disconnected)); - }) + } } // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted - test!(fn destroy_upgraded_shared_port_when_sender_still_active() { + test! { fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = channel(); let (tx2, rx2) = channel(); spawn(move|| { @@ -1516,9 +1516,9 @@ mod test { // wait for the child task to exit before we exit rx2.recv(); - }) + } } - test!(fn sends_off_the_runtime() { + test! { fn sends_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = channel(); @@ -1531,9 +1531,9 @@ mod test { rx.recv(); } t.join(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = channel(); @@ -1554,7 +1554,7 @@ mod test { } t.join(); pdone.recv(); - }) + } } } #[cfg(test)] @@ -1569,57 +1569,57 @@ mod sync_tests { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn drop_full() { + test! { fn drop_full() { let (tx, _rx) = sync_channel(1); tx.send(box 1i); - }) + } } - test!(fn smoke_shared() { + test! { fn smoke_shared() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_threads() { + test! { fn smoke_threads() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = sync_channel::<int>(0); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone2() { + test! { fn smoke_shared_port_gone2() { let (tx, rx) = sync_channel::<int>(0); drop(rx); let tx2 = tx.clone(); drop(tx); tx2.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent() { + test! { fn port_gone_concurrent() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { rx.recv(); }); loop { tx.send(1) } - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent_shared() { + test! { fn port_gone_concurrent_shared() { let (tx, rx) = sync_channel::<int>(0); let tx2 = tx.clone(); spawn(move|| { @@ -1629,32 +1629,32 @@ mod sync_tests { tx.send(1); tx2.send(1); } - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone() { + test! { fn smoke_chan_gone() { let (tx, rx) = sync_channel::<int>(0); drop(tx); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone_shared() { + test! { fn smoke_chan_gone_shared() { let (tx, rx) = sync_channel::<()>(0); let tx2 = tx.clone(); drop(tx); drop(tx2); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn chan_gone_concurrent() { + test! { fn chan_gone_concurrent() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 10000) { tx.send(1); } @@ -1662,9 +1662,9 @@ mod sync_tests { for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } - }) + } } - test!(fn stress_shared() { + test! { fn stress_shared() { static AMT: uint = 1000; static NTHREADS: uint = 8; let (tx, rx) = sync_channel::<int>(0); @@ -1689,28 +1689,28 @@ mod sync_tests { } drop(tx); drx.recv(); - }) + } } - test!(fn oneshot_single_thread_close_port_first() { + test! { fn oneshot_single_thread_close_port_first() { // Simple test of closing without sending let (_tx, rx) = sync_channel::<int>(0); drop(rx); - }) + } } - test!(fn oneshot_single_thread_close_chan_first() { + test! { fn oneshot_single_thread_close_chan_first() { // Simple test of closing without sending let (tx, _rx) = sync_channel::<int>(0); drop(tx); - }) + } } - test!(fn oneshot_single_thread_send_port_close() { + test! { fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = sync_channel::<Box<int>>(0); drop(rx); tx.send(box 0); - } #[should_fail]) + } #[should_fail] } - test!(fn oneshot_single_thread_recv_chan_close() { + test! { fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = task::try(move|| { let (tx, rx) = sync_channel::<int>(0); @@ -1719,72 +1719,72 @@ mod sync_tests { }); // What is our res? assert!(res.is_err()); - }) + } } - test!(fn oneshot_single_thread_send_then_recv() { + test! { fn oneshot_single_thread_send_then_recv() { let (tx, rx) = sync_channel::<Box<int>>(1); tx.send(box 10); assert!(rx.recv() == box 10); - }) + } } - test!(fn oneshot_single_thread_try_send_open() { + test! { fn oneshot_single_thread_try_send_open() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(10), Ok(())); assert!(rx.recv() == 10); - }) + } } - test!(fn oneshot_single_thread_try_send_closed() { + test! { fn oneshot_single_thread_try_send_closed() { let (tx, rx) = sync_channel::<int>(0); drop(rx); assert_eq!(tx.try_send(10), Err(RecvDisconnected(10))); - }) + } } - test!(fn oneshot_single_thread_try_send_closed2() { + test! { fn oneshot_single_thread_try_send_closed2() { let (tx, _rx) = sync_channel::<int>(0); assert_eq!(tx.try_send(10), Err(Full(10))); - }) + } } - test!(fn oneshot_single_thread_try_recv_open() { + test! { fn oneshot_single_thread_try_recv_open() { let (tx, rx) = sync_channel::<int>(1); tx.send(10); assert!(rx.recv_opt() == Ok(10)); - }) + } } - test!(fn oneshot_single_thread_try_recv_closed() { + test! { fn oneshot_single_thread_try_recv_closed() { let (tx, rx) = sync_channel::<int>(0); drop(tx); assert!(rx.recv_opt() == Err(())); - }) + } } - test!(fn oneshot_single_thread_peek_data() { + test! { fn oneshot_single_thread_peek_data() { let (tx, rx) = sync_channel::<int>(1); - assert_eq!(rx.try_recv(), Err(Empty)) + assert_eq!(rx.try_recv(), Err(Empty)); tx.send(10); assert_eq!(rx.try_recv(), Ok(10)); - }) + } } - test!(fn oneshot_single_thread_peek_close() { + test! { fn oneshot_single_thread_peek_close() { let (tx, rx) = sync_channel::<int>(0); drop(tx); assert_eq!(rx.try_recv(), Err(Disconnected)); assert_eq!(rx.try_recv(), Err(Disconnected)); - }) + } } - test!(fn oneshot_single_thread_peek_open() { + test! { fn oneshot_single_thread_peek_open() { let (_tx, rx) = sync_channel::<int>(0); assert_eq!(rx.try_recv(), Err(Empty)); - }) + } } - test!(fn oneshot_multi_task_recv_then_send() { + test! { fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { assert!(rx.recv() == box 10); }); tx.send(box 10); - }) + } } - test!(fn oneshot_multi_task_recv_then_close() { + test! { fn oneshot_multi_task_recv_then_close() { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { drop(tx); @@ -1793,9 +1793,9 @@ mod sync_tests { assert!(rx.recv() == box 10); }); assert!(res.is_err()); - }) + } } - test!(fn oneshot_multi_thread_close_stress() { + test! { fn oneshot_multi_thread_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1803,9 +1803,9 @@ mod sync_tests { }); drop(tx); } - }) + } } - test!(fn oneshot_multi_thread_send_close_stress() { + test! { fn oneshot_multi_thread_send_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1815,9 +1815,9 @@ mod sync_tests { tx.send(1); }); } - }) + } } - test!(fn oneshot_multi_thread_recv_close_stress() { + test! { fn oneshot_multi_thread_recv_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1832,9 +1832,9 @@ mod sync_tests { }); }); } - }) + } } - test!(fn oneshot_multi_thread_send_recv_stress() { + test! { fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { @@ -1844,9 +1844,9 @@ mod sync_tests { assert!(rx.recv() == box 10i); }); } - }) + } } - test!(fn stream_send_recv_stress() { + test! { fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<Box<int>>(0); @@ -1871,16 +1871,16 @@ mod sync_tests { }); } } - }) + } } - test!(fn recv_a_lot() { + test! { fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = sync_channel(10000); for _ in range(0u, 10000) { tx.send(()); } for _ in range(0u, 10000) { rx.recv(); } - }) + } } - test!(fn shared_chan_stress() { + test! { fn shared_chan_stress() { let (tx, rx) = sync_channel(0); let total = stress_factor() + 100; for _ in range(0, total) { @@ -1893,9 +1893,9 @@ mod sync_tests { for _ in range(0, total) { rx.recv(); } - }) + } } - test!(fn test_nested_recv_iter() { + test! { fn test_nested_recv_iter() { let (tx, rx) = sync_channel::<int>(0); let (total_tx, total_rx) = sync_channel::<int>(0); @@ -1912,9 +1912,9 @@ mod sync_tests { tx.send(2); drop(tx); assert_eq!(total_rx.recv(), 6); - }) + } } - test!(fn test_recv_iter_break() { + test! { fn test_recv_iter_break() { let (tx, rx) = sync_channel::<int>(0); let (count_tx, count_rx) = sync_channel(0); @@ -1936,9 +1936,9 @@ mod sync_tests { let _ = tx.try_send(2); drop(tx); assert_eq!(count_rx.recv(), 4); - }) + } } - test!(fn try_recv_states() { + test! { fn try_recv_states() { let (tx1, rx1) = sync_channel::<int>(1); let (tx2, rx2) = sync_channel::<()>(1); let (tx3, rx3) = sync_channel::<()>(1); @@ -1959,11 +1959,11 @@ mod sync_tests { tx2.send(()); rx3.recv(); assert_eq!(rx1.try_recv(), Err(Disconnected)); - }) + } } // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted - test!(fn destroy_upgraded_shared_port_when_sender_still_active() { + test! { fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = sync_channel::<()>(0); let (tx2, rx2) = sync_channel::<()>(0); spawn(move|| { @@ -1981,9 +1981,9 @@ mod sync_tests { // wait for the child task to exit before we exit rx2.recv(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = sync_channel::<()>(0); @@ -2004,28 +2004,28 @@ mod sync_tests { } t.join(); pdone.recv(); - }) + } } - test!(fn send_opt1() { + test! { fn send_opt1() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { rx.recv(); }); assert_eq!(tx.send_opt(1), Ok(())); - }) + } } - test!(fn send_opt2() { + test! { fn send_opt2() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt3() { + test! { fn send_opt3() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.send_opt(1), Ok(())); spawn(move|| { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt4() { + test! { fn send_opt4() { let (tx, rx) = sync_channel::<int>(0); let tx2 = tx.clone(); let (done, donerx) = channel(); @@ -2041,36 +2041,36 @@ mod sync_tests { drop(rx); donerx.recv(); donerx.recv(); - }) + } } - test!(fn try_send1() { + test! { fn try_send1() { let (tx, _rx) = sync_channel::<int>(0); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send2() { + test! { fn try_send2() { let (tx, _rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(1), Ok(())); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send3() { + test! { fn try_send3() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(1), Ok(())); drop(rx); assert_eq!(tx.try_send(1), Err(RecvDisconnected(1))); - }) + } } - test!(fn try_send4() { + test! { fn try_send4() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 1000) { task::deschedule(); } assert_eq!(tx.try_send(1), Ok(())); }); assert_eq!(rx.recv(), 1); - } #[ignore(reason = "flaky on libnative")]) + } #[ignore(reason = "flaky on libnative")] } - test!(fn issue_15761() { + test! { fn issue_15761() { fn repro() { let (tx1, rx1) = sync_channel::<()>(3); let (tx2, rx2) = sync_channel::<()>(3); @@ -2087,5 +2087,5 @@ mod sync_tests { for _ in range(0u, 100) { repro() } - }) + } } } |
