@@ -699,6 +699,20 @@ fn no_senders_notification() {
699699 assert ! ( result. unwrap_err( ) . channel_is_closed( ) ) ;
700700}
701701
702+ /// Checks that a broken pipe notification is returned by `send()`
703+ /// after the receive end was closed.
704+ #[ test]
705+ fn no_receiver_notification ( ) {
706+ let ( sender, receiver) = platform:: channel ( ) . unwrap ( ) ;
707+ drop ( receiver) ;
708+ let data: & [ u8 ] = b"1234567" ;
709+ let result = sender. send ( data, vec ! [ ] , vec ! [ ] ) ;
710+ assert ! ( result. is_err( ) ) ;
711+ // We don't have an actual method for distinguishing a "broken pipe" error --
712+ // but at least it's not supposed to signal the same condition as closing the sender.
713+ assert ! ( !result. unwrap_err( ) . channel_is_closed( ) ) ;
714+ }
715+
702716#[ test]
703717fn shared_memory ( ) {
704718 let ( tx, rx) = platform:: channel ( ) . unwrap ( ) ;
@@ -730,6 +744,23 @@ fn try_recv() {
730744 assert ! ( rx. try_recv( ) . is_err( ) ) ;
731745}
732746
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+
733764#[ test]
734765fn try_recv_large ( ) {
735766 let ( tx, rx) = platform:: channel ( ) . unwrap ( ) ;
0 commit comments