File tree 3 files changed +44
-3
lines changed
3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ mod test {
127
127
}
128
128
129
129
fn mk ( v : uint ) -> ( ~IdleWatcher , Chan ) {
130
- let rc = Rc :: from_send ( RefCell :: new ( ( None , 0 ) ) ) ;
130
+ let rc = Rc :: new ( RefCell :: new ( ( None , 0 ) ) ) ;
131
131
let cb = ~MyCallback ( rc. clone ( ) , v) ;
132
132
let cb = cb as ~Callback : ;
133
133
let cb = unsafe { cast:: transmute ( cb) } ;
Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ mod tests {
509
509
}
510
510
}
511
511
512
- let i = Rc :: from_send ( RefCell :: new ( 0 ) ) ;
512
+ let i = Rc :: new ( RefCell :: new ( 0 ) ) ;
513
513
{
514
514
let x = R ( i. clone ( ) ) ;
515
515
let opt = Some ( x) ;
Original file line number Diff line number Diff line change @@ -172,8 +172,49 @@ impl<T> Clone for Weak<T> {
172
172
173
173
#[ cfg( test) ]
174
174
mod tests {
175
+ use prelude:: * ;
175
176
use super :: * ;
176
- use prelude:: drop;
177
+ use cell:: RefCell ;
178
+
179
+ #[ test]
180
+ fn test_clone ( ) {
181
+ let x = Rc :: new ( RefCell :: new ( 5 ) ) ;
182
+ let y = x. clone ( ) ;
183
+ x. borrow ( ) . with_mut ( |inner| {
184
+ * inner = 20 ;
185
+ } ) ;
186
+ assert_eq ! ( y. borrow( ) . with( |v| * v) , 20 ) ;
187
+ }
188
+
189
+ #[ test]
190
+ fn test_deep_clone ( ) {
191
+ let x = Rc :: new ( RefCell :: new ( 5 ) ) ;
192
+ let y = x. deep_clone ( ) ;
193
+ x. borrow ( ) . with_mut ( |inner| {
194
+ * inner = 20 ;
195
+ } ) ;
196
+ assert_eq ! ( y. borrow( ) . with( |v| * v) , 5 ) ;
197
+ }
198
+
199
+ #[ test]
200
+ fn test_simple ( ) {
201
+ let x = Rc :: new ( 5 ) ;
202
+ assert_eq ! ( * x. borrow( ) , 5 ) ;
203
+ }
204
+
205
+ #[ test]
206
+ fn test_simple_clone ( ) {
207
+ let x = Rc :: new ( 5 ) ;
208
+ let y = x. clone ( ) ;
209
+ assert_eq ! ( * x. borrow( ) , 5 ) ;
210
+ assert_eq ! ( * y. borrow( ) , 5 ) ;
211
+ }
212
+
213
+ #[ test]
214
+ fn test_destructor ( ) {
215
+ let x = Rc :: new ( ~5 ) ;
216
+ assert_eq ! ( * * x. borrow( ) , 5 ) ;
217
+ }
177
218
178
219
#[ test]
179
220
fn test_live ( ) {
You can’t perform that action at this time.
0 commit comments