Simplify drop test (Rc is redundant)

This commit is contained in:
root
2015-05-21 15:45:16 +02:00
parent 14550015d9
commit 00466e6efd
2 changed files with 17 additions and 19 deletions
+8 -9
View File
@@ -93,14 +93,13 @@ fn test_no_nonnullable_opt() {
#[test]
fn test_drop() {
use std::rc::Rc;
use std::cell::Cell;
let flag = Rc::new(Cell::new(0));
let flag = &Cell::new(0);
struct Foo(Rc<Cell<i32>>);
struct Bump<'a>(&'a Cell<i32>);
impl Drop for Foo {
impl<'a> Drop for Bump<'a> {
fn drop(&mut self) {
let n = self.0.get();
self.0.set(n + 1);
@@ -108,7 +107,7 @@ fn test_drop() {
}
{
let _ = NoDrop::new([Foo(flag.clone()), Foo(flag.clone())]);
let _ = NoDrop::new([Bump(flag), Bump(flag)]);
}
assert_eq!(flag.get(), 0);
@@ -117,10 +116,10 @@ fn test_drop() {
{
let mut array = NoDrop::new(Vec::new());
array.push(vec![Foo(flag.clone())]);
array.push(vec![Foo(flag.clone()), Foo(flag.clone())]);
array.push(vec![Bump(flag)]);
array.push(vec![Bump(flag), Bump(flag)]);
array.push(vec![]);
array.push(vec![Foo(flag.clone())]);
array.push(vec![Bump(flag)]);
drop(array.pop());
assert_eq!(flag.get(), 1);
drop(array.pop());
@@ -134,7 +133,7 @@ fn test_drop() {
flag.set(0);
{
let mut array = NoDrop::new(Foo(flag.clone()));
let array = NoDrop::new(Bump(flag));
array.into_inner();
assert_eq!(flag.get(), 1);
}