@@ -3,6 +3,7 @@ use futures_test::task::noop_context;
33use std:: { future:: Future , task:: Poll } ;
44use tokio:: io:: { AsyncRead , AsyncReadExt , AsyncWrite , AsyncWriteExt , ReadBuf } ;
55use tokio_test:: { assert_pending, assert_ready_err} ;
6+ use tokio_test:: task:: spawn;
67use tokio_util:: io:: simplex;
78
89/// Sanity check for single-threaded operation.
@@ -139,6 +140,26 @@ async fn shutdown_sender_1() {
139140 tx. shutdown ( ) . await . unwrap ( ) ;
140141}
141142
143+ /// The `Sender::poll_shutdown` should wake up the `Receiver`
144+ #[ tokio:: test]
145+ async fn shutdown_sender_2 ( ) {
146+ let ( mut tx, mut rx) = simplex:: new ( 32 ) ;
147+
148+ let mut buf = vec ! [ ] ;
149+ let mut read_task = spawn ( rx. read_to_end ( & mut buf) ) ;
150+ assert_pending ! ( read_task. poll( ) ) ;
151+
152+ tx. write_u8 ( 1 ) . await . unwrap ( ) ;
153+ assert_pending ! ( read_task. poll( ) ) ;
154+
155+ assert ! ( !read_task. is_woken( ) ) ;
156+ tx. shutdown ( ) . await . unwrap ( ) ;
157+ assert ! ( read_task. is_woken( ) ) ;
158+
159+ read_task. await . unwrap ( ) ;
160+ assert_eq ! ( buf, vec![ 1 ] ) ;
161+ }
162+
142163/// Both `Sender` and `Receiver` should yield periodically
143164/// in a tight-loop.
144165#[ tokio:: test]
0 commit comments