File tree 1 file changed +30
-0
lines changed
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() {
63
63
assert ! ( tx. send( 1 ) . is_err( ) ) ;
64
64
}
65
65
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
+
66
84
#[ test]
67
85
fn smoke_shared_port_gone ( ) {
68
86
let ( tx, rx) = channel :: < i32 > ( ) ;
@@ -124,6 +142,18 @@ fn chan_gone_concurrent() {
124
142
while rx. recv ( ) . is_ok ( ) { }
125
143
}
126
144
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
+
127
157
#[ test]
128
158
fn stress ( ) {
129
159
let count = if cfg ! ( miri) { 100 } else { 10000 } ;
You can’t perform that action at this time.
0 commit comments