File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,24 @@ fn smoke_port_gone() {
6363 assert ! ( tx. send( 1 ) . is_err( ) ) ;
6464}
6565
66+ #[ test]
67+ fn smoke_receiver_clone ( ) {
68+ let ( tx, rx) = channel :: < i32 > ( ) ;
69+ let rx2 = rx. clone ( ) ;
70+ drop ( rx) ;
71+ tx. send ( 1 ) . unwrap ( ) ;
72+ assert_eq ! ( rx2. recv( ) . unwrap( ) , 1 ) ;
73+ }
74+
75+ #[ test]
76+ fn smoke_receiver_clone_port_gone ( ) {
77+ let ( tx, rx) = channel :: < i32 > ( ) ;
78+ let rx2 = rx. clone ( ) ;
79+ drop ( rx) ;
80+ drop ( rx2) ;
81+ assert ! ( tx. send( 1 ) . is_err( ) ) ;
82+ }
83+
6684#[ test]
6785fn smoke_shared_port_gone ( ) {
6886 let ( tx, rx) = channel :: < i32 > ( ) ;
@@ -124,6 +142,18 @@ fn chan_gone_concurrent() {
124142 while rx. recv ( ) . is_ok ( ) { }
125143}
126144
145+ #[ test]
146+ fn receiver_cloning ( ) {
147+ let ( tx, rx) = channel :: < i32 > ( ) ;
148+ let rx2 = rx. clone ( ) ;
149+
150+ tx. send ( 1 ) . unwrap ( ) ;
151+ tx. send ( 2 ) . unwrap ( ) ;
152+
153+ assert_eq ! ( rx2. recv( ) , Ok ( 1 ) ) ;
154+ assert_eq ! ( rx. recv( ) , Ok ( 2 ) ) ;
155+ }
156+
127157#[ test]
128158fn stress ( ) {
129159 let count = if cfg ! ( miri) { 100 } else { 10000 } ;
You can’t perform that action at this time.
0 commit comments