futures: tests/io_read_until.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(feature = "executor")]
+#[test]
+fn read_until() {
use futures::executor::block_on;
-use futures::future::{Future, FutureExt};
-use futures::stream::{self, StreamExt, TryStreamExt};
use futures::io::{AsyncBufReadExt, Cursor};
-use futures::task::Poll;
-use futures_test::io::AsyncReadTestExt;
-use futures_test::task::noop_context;
-#[test]
-fn read_until() {
let mut buf = Cursor::new(b"12");
let mut v = Vec::new();
assert_eq!(block_on(buf.read_until(b'3', &mut v)).unwrap(), 2);
@@ -25,7 +21,17 @@ fn read_until() {
assert_eq!(v, []);
}
+
+#[cfg(feature = "std")]
+#[test]
+fn maybe_pending() {
+ use futures::future::Future;
+
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) {
@@ -34,8 +40,10 @@ fn run<F: Future + Unpin>(mut f: F) -> F::Output {
}
}
-#[test]
-fn maybe_pending() {
+ use futures::stream::{self, StreamExt, TryStreamExt};
+ use futures::io::AsyncBufReadExt;
+ use futures_test::io::AsyncReadTestExt;
+
let mut buf = b"12".interleave_pending();
let mut v = Vec::new();
assert_eq!(run(buf.read_until(b'3', &mut v)).unwrap(), 2);
