futures: tests/oneshot.rs: Don't break w/o "alloc"
Symbols/Imports pushed down / localised
Tests gated with cfg()
Tests now build and pass with all valid feature combinations
See previous commits for details and rationale
+#[cfg(feature = "alloc")] // channel
+#[test]
+fn oneshot_send1() {
use futures::channel::oneshot;
-use futures::future::{FutureExt, TryFutureExt};
+ use futures::future::TryFutureExt;
use futures_test::future::FutureTestExt;
use std::sync::mpsc;
use std::thread;
-#[test]
-fn oneshot_send1() {
let (tx1, rx1) = oneshot::channel::<i32>();
let (tx2, rx2) = mpsc::channel();
@@ -15,8 +16,15 @@ fn oneshot_send1() {
t.join().unwrap();
}
+#[cfg(feature = "alloc")] // channel
#[test]
fn oneshot_send2() {
+ use futures::channel::oneshot;
+ use futures::future::TryFutureExt;
+ use futures_test::future::FutureTestExt;
+ use std::sync::mpsc;
+ use std::thread;
+
let (tx1, rx1) = oneshot::channel::<i32>();
let (tx2, rx2) = mpsc::channel();
@@ -25,8 +33,15 @@ fn oneshot_send2() {
assert_eq!(1, rx2.recv().unwrap());
}
+#[cfg(feature = "alloc")] // channel
#[test]
fn oneshot_send3() {
+ use futures::channel::oneshot;
+ use futures::future::TryFutureExt;
+ use futures_test::future::FutureTestExt;
+ use std::sync::mpsc;
+ use std::thread;
+
let (tx1, rx1) = oneshot::channel::<i32>();
let (tx2, rx2) = mpsc::channel();
@@ -35,8 +50,14 @@ fn oneshot_send3() {
assert_eq!(1, rx2.recv().unwrap());
}
+#[cfg(feature = "alloc")] // channel
#[test]
fn oneshot_drop_tx1() {
+ use futures::channel::oneshot;
+ use futures::future::FutureExt;
+ use futures_test::future::FutureTestExt;
+ use std::sync::mpsc;
+
let (tx1, rx1) = oneshot::channel::<i32>();
let (tx2, rx2) = mpsc::channel();
@@ -46,8 +67,15 @@ fn oneshot_drop_tx1() {
assert_eq!(Err(oneshot::Canceled), rx2.recv().unwrap());
}
+#[cfg(feature = "alloc")] // channel
#[test]
fn oneshot_drop_tx2() {
+ use futures::channel::oneshot;
+ use futures::future::FutureExt;
+ use futures_test::future::FutureTestExt;
+ use std::sync::mpsc;
+ use std::thread;
+
let (tx1, rx1) = oneshot::channel::<i32>();
let (tx2, rx2) = mpsc::channel();
@@ -58,8 +86,11 @@ fn oneshot_drop_tx2() {
assert_eq!(Err(oneshot::Canceled), rx2.recv().unwrap());
}
+#[cfg(feature = "alloc")] // channel
#[test]
fn oneshot_drop_rx() {
+ use futures::channel::oneshot;
+
let (tx, rx) = oneshot::channel::<i32>();
drop(rx);
assert_eq!(Err(2), tx.send(2));
