futures: tests/stream_into_async_read.rs: Don't break w/o "std"
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 = "std")] // io::
+#[test]
+fn test_into_async_read() {
use core::pin::Pin;
-use futures::io::{AsyncRead, AsyncBufRead};
+ use futures::io::AsyncRead;
use futures::stream::{self, TryStreamExt};
use futures::task::Poll;
use futures_test::{task::noop_context, stream::StreamTestExt};
@@ -24,28 +27,6 @@ macro_rules! assert_read {
};
}
-macro_rules! assert_fill_buf {
- ($reader:expr, $buf:expr) => {
- let mut cx = noop_context();
- loop {
- match Pin::new(&mut $reader).poll_fill_buf(&mut cx) {
- Poll::Ready(Ok(x)) => {
- assert_eq!(x, $buf);
- break;
- }
- Poll::Ready(Err(err)) => {
- panic!("assertion failed: expected value but got {}", err);
- }
- Poll::Pending => {
- continue;
- }
- }
- }
- };
-}
-
-#[test]
-fn test_into_async_read() {
let stream = stream::iter((1..=3).flat_map(|_| vec![Ok(vec![]), Ok(vec![1, 2, 3, 4, 5])]));
let mut reader = stream.interleave_pending().into_async_read();
let mut buf = vec![0; 3];
@@ -71,8 +52,35 @@ fn test_into_async_read() {
assert_read!(reader, &mut buf, 0);
}
+#[cfg(feature = "std")] // io::
#[test]
fn test_into_async_bufread() -> std::io::Result<()> {
+ use core::pin::Pin;
+ use futures::io::AsyncBufRead;
+ use futures::stream::{self, TryStreamExt};
+ use futures::task::Poll;
+ use futures_test::{task::noop_context, stream::StreamTestExt};
+
+ macro_rules! assert_fill_buf {
+ ($reader:expr, $buf:expr) => {
+ let mut cx = noop_context();
+ loop {
+ match Pin::new(&mut $reader).poll_fill_buf(&mut cx) {
+ Poll::Ready(Ok(x)) => {
+ assert_eq!(x, $buf);
+ break;
+ }
+ Poll::Ready(Err(err)) => {
+ panic!("assertion failed: expected value but got {}", err);
+ }
+ Poll::Pending => {
+ continue;
+ }
+ }
+ }
+ };
+ }
+
let stream = stream::iter((1..=2).flat_map(|_| vec![Ok(vec![]), Ok(vec![1, 2, 3, 4, 5])]));
let mut reader = stream.interleave_pending().into_async_read();
