Skip to content

Commit 8aae1ee

Browse files
committed
Move cell exterior test into library unit tests
1 parent 4eff9b0 commit 8aae1ee

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

library/core/tests/cell.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,30 @@ fn cell_into_inner() {
303303
assert_eq!("Hello world".to_owned(), cell.into_inner());
304304
}
305305

306+
#[test]
307+
fn cell_exterior() {
308+
#[derive(Copy, Clone)]
309+
#[allow(dead_code)]
310+
struct Point {
311+
x: isize,
312+
y: isize,
313+
z: isize,
314+
}
315+
316+
fn f(p: &Cell<Point>) {
317+
assert_eq!(p.get().z, 12);
318+
p.set(Point { x: 10, y: 11, z: 13 });
319+
assert_eq!(p.get().z, 13);
320+
}
321+
322+
let a = Point { x: 10, y: 11, z: 12 };
323+
let b = &Cell::new(a);
324+
assert_eq!(b.get().z, 12);
325+
f(b);
326+
assert_eq!(a.z, 12);
327+
assert_eq!(b.get().z, 13);
328+
}
329+
306330
#[test]
307331
fn refcell_default() {
308332
let cell: RefCell<u64> = Default::default();

src/test/ui/exterior.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)