diff options
| author | Alexis Bourget <alexis.bourget@gmail.com> | 2020-09-07 23:59:40 +0200 |
|---|---|---|
| committer | Alexis Bourget <alexis.bourget@gmail.com> | 2020-09-21 21:28:33 +0200 |
| commit | 8aae1eee94f481bd955cff473deae1f03c313451 (patch) | |
| tree | 6e6c75016aeb4e73d24470b81676ca055f8bcae2 | |
| parent | 4eff9b0b29a8898c839d46f3c66526710afed68a (diff) | |
| download | rust-8aae1eee94f481bd955cff473deae1f03c313451.tar.gz rust-8aae1eee94f481bd955cff473deae1f03c313451.zip | |
Move cell exterior test into library unit tests
| -rw-r--r-- | library/core/tests/cell.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/exterior.rs | 24 |
2 files changed, 24 insertions, 24 deletions
diff --git a/library/core/tests/cell.rs b/library/core/tests/cell.rs index 801b60be0f0..2f662d90280 100644 --- a/library/core/tests/cell.rs +++ b/library/core/tests/cell.rs @@ -304,6 +304,30 @@ fn cell_into_inner() { } #[test] +fn cell_exterior() { + #[derive(Copy, Clone)] + #[allow(dead_code)] + struct Point { + x: isize, + y: isize, + z: isize, + } + + fn f(p: &Cell<Point>) { + assert_eq!(p.get().z, 12); + p.set(Point { x: 10, y: 11, z: 13 }); + assert_eq!(p.get().z, 13); + } + + let a = Point { x: 10, y: 11, z: 12 }; + let b = &Cell::new(a); + assert_eq!(b.get().z, 12); + f(b); + assert_eq!(a.z, 12); + assert_eq!(b.get().z, 13); +} + +#[test] fn refcell_default() { let cell: RefCell<u64> = Default::default(); assert_eq!(0, *cell.borrow()); diff --git a/src/test/ui/exterior.rs b/src/test/ui/exterior.rs deleted file mode 100644 index 6f2c37926be..00000000000 --- a/src/test/ui/exterior.rs +++ /dev/null @@ -1,24 +0,0 @@ -// run-pass - -#![allow(dead_code)] - - -use std::cell::Cell; - -#[derive(Copy, Clone)] -struct Point {x: isize, y: isize, z: isize} - -fn f(p: &Cell<Point>) { - assert_eq!(p.get().z, 12); - p.set(Point {x: 10, y: 11, z: 13}); - assert_eq!(p.get().z, 13); -} - -pub fn main() { - let a: Point = Point {x: 10, y: 11, z: 12}; - let b: &Cell<Point> = &Cell::new(a); - assert_eq!(b.get().z, 12); - f(b); - assert_eq!(a.z, 12); - assert_eq!(b.get().z, 13); -} |
