futures: tests/io_read_to_string.rs: Don't break w/o features
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(all(feature = "std", feature = "executor"))]
+#[test]
+fn read_to_string() {
use futures::executor::block_on;
-use futures::future::{Future, FutureExt};
-use futures::stream::{self, StreamExt, TryStreamExt};
use futures::io::{AsyncReadExt, Cursor};
-use futures::task::Poll;
-use futures_test::io::AsyncReadTestExt;
-use futures_test::task::noop_context;
-#[test]
-fn read_to_string() {
let mut c = Cursor::new(&b""[..]);
let mut v = String::new();
assert_eq!(block_on(c.read_to_string(&mut v)).unwrap(), 0);
@@ -23,7 +19,19 @@ fn read_to_string() {
assert!(block_on(c.read_to_string(&mut v)).is_err());
}
+#[cfg(feature = "std")]
+#[test]
+fn interleave_pending() {
+ use futures::future::Future;
+ use futures::stream::{self, StreamExt, TryStreamExt};
+ use futures::io::AsyncReadExt;
+ use futures_test::io::AsyncReadTestExt;
+
fn run<F: Future + Unpin>(mut f: F) -> F::Output {
+ use futures::future::FutureExt;
+ use futures_test::task::noop_context;
+ use futures::task::Poll;
+
let mut cx = noop_context();
loop {
if let Poll::Ready(x) = f.poll_unpin(&mut cx) {
@@ -31,9 +39,6 @@ fn run<F: Future + Unpin>(mut f: F) -> F::Output {
}
}
}
-
-#[test]
-fn interleave_pending() {
let mut buf = stream::iter(vec![&b"12"[..], &b"33"[..], &b"3"[..]])
.map(Ok)
.into_async_read()
