@@ -699,6 +699,20 @@ fn no_senders_notification() {
699
699
assert ! ( result. unwrap_err( ) . channel_is_closed( ) ) ;
700
700
}
701
701
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
+
702
716
#[ test]
703
717
fn shared_memory ( ) {
704
718
let ( tx, rx) = platform:: channel ( ) . unwrap ( ) ;
@@ -730,6 +744,23 @@ fn try_recv() {
730
744
assert ! ( rx. try_recv( ) . is_err( ) ) ;
731
745
}
732
746
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
+
733
764
#[ test]
734
765
fn try_recv_large ( ) {
735
766
let ( tx, rx) = platform:: channel ( ) . unwrap ( ) ;
0 commit comments