File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -744,6 +744,23 @@ fn try_recv() {
744744 assert ! ( rx. try_recv( ) . is_err( ) ) ;
745745}
746746
747+ /// Checks that a channel closed notification is returned by `try_recv()`.
748+ ///
749+ /// Also checks that the "no data" notification returned by `try_recv()`
750+ /// when no data is pending but before the channel is closed,
751+ /// is distinguishable from the actual "channel closed" notification.
752+ #[ test]
753+ fn no_senders_notification_try_recv ( ) {
754+ let ( sender, receiver) = platform:: channel ( ) . unwrap ( ) ;
755+ let result = receiver. try_recv ( ) ;
756+ assert ! ( result. is_err( ) ) ;
757+ assert ! ( !result. unwrap_err( ) . channel_is_closed( ) ) ;
758+ drop ( sender) ;
759+ let result = receiver. try_recv ( ) ;
760+ assert ! ( result. is_err( ) ) ;
761+ assert ! ( result. unwrap_err( ) . channel_is_closed( ) ) ;
762+ }
763+
747764#[ test]
748765fn try_recv_large ( ) {
749766 let ( tx, rx) = platform:: channel ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments