1
Fork 0

Update TypedArena tests

This commit is contained in:
Oliver Scherer 2018-10-17 09:11:55 +02:00
parent 54eb222c40
commit bf3d40aa7e
3 changed files with 13 additions and 13 deletions

View file

@ -500,7 +500,7 @@ mod tests {
#[test] #[test]
pub fn test_unused() { pub fn test_unused() {
let arena: TypedArena<Point> = TypedArena::new(); let arena: TypedArena<Point> = TypedArena::default();
assert!(arena.chunks.borrow().is_empty()); assert!(arena.chunks.borrow().is_empty());
} }
@ -538,7 +538,7 @@ mod tests {
} }
} }
let arena = Wrap(TypedArena::new()); let arena = Wrap(TypedArena::default());
let result = arena.alloc_outer(|| Outer { let result = arena.alloc_outer(|| Outer {
inner: arena.alloc_inner(|| Inner { value: 10 }), inner: arena.alloc_inner(|| Inner { value: 10 }),
@ -549,7 +549,7 @@ mod tests {
#[test] #[test]
pub fn test_copy() { pub fn test_copy() {
let arena = TypedArena::new(); let arena = TypedArena::default();
for _ in 0..100000 { for _ in 0..100000 {
arena.alloc(Point { x: 1, y: 2, z: 3 }); arena.alloc(Point { x: 1, y: 2, z: 3 });
} }
@ -557,7 +557,7 @@ mod tests {
#[bench] #[bench]
pub fn bench_copy(b: &mut Bencher) { pub fn bench_copy(b: &mut Bencher) {
let arena = TypedArena::new(); let arena = TypedArena::default();
b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 })) b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 }))
} }
@ -576,7 +576,7 @@ mod tests {
#[test] #[test]
pub fn test_noncopy() { pub fn test_noncopy() {
let arena = TypedArena::new(); let arena = TypedArena::default();
for _ in 0..100000 { for _ in 0..100000 {
arena.alloc(Noncopy { arena.alloc(Noncopy {
string: "hello world".to_string(), string: "hello world".to_string(),
@ -587,7 +587,7 @@ mod tests {
#[test] #[test]
pub fn test_typed_arena_zero_sized() { pub fn test_typed_arena_zero_sized() {
let arena = TypedArena::new(); let arena = TypedArena::default();
for _ in 0..100000 { for _ in 0..100000 {
arena.alloc(()); arena.alloc(());
} }
@ -595,7 +595,7 @@ mod tests {
#[test] #[test]
pub fn test_typed_arena_clear() { pub fn test_typed_arena_clear() {
let mut arena = TypedArena::new(); let mut arena = TypedArena::default();
for _ in 0..10 { for _ in 0..10 {
arena.clear(); arena.clear();
for _ in 0..10000 { for _ in 0..10000 {
@ -620,7 +620,7 @@ mod tests {
fn test_typed_arena_drop_count() { fn test_typed_arena_drop_count() {
let counter = Cell::new(0); let counter = Cell::new(0);
{ {
let arena: TypedArena<DropCounter> = TypedArena::new(); let arena: TypedArena<DropCounter> = TypedArena::default();
for _ in 0..100 { for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak. // Allocate something with drop glue to make sure it doesn't leak.
arena.alloc(DropCounter { count: &counter }); arena.alloc(DropCounter { count: &counter });
@ -632,7 +632,7 @@ mod tests {
#[test] #[test]
fn test_typed_arena_drop_on_clear() { fn test_typed_arena_drop_on_clear() {
let counter = Cell::new(0); let counter = Cell::new(0);
let mut arena: TypedArena<DropCounter> = TypedArena::new(); let mut arena: TypedArena<DropCounter> = TypedArena::default();
for i in 0..10 { for i in 0..10 {
for _ in 0..100 { for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak. // Allocate something with drop glue to make sure it doesn't leak.
@ -659,7 +659,7 @@ mod tests {
fn test_typed_arena_drop_small_count() { fn test_typed_arena_drop_small_count() {
DROP_COUNTER.with(|c| c.set(0)); DROP_COUNTER.with(|c| c.set(0));
{ {
let arena: TypedArena<SmallDroppable> = TypedArena::new(); let arena: TypedArena<SmallDroppable> = TypedArena::default();
for _ in 0..100 { for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak. // Allocate something with drop glue to make sure it doesn't leak.
arena.alloc(SmallDroppable); arena.alloc(SmallDroppable);
@ -671,7 +671,7 @@ mod tests {
#[bench] #[bench]
pub fn bench_noncopy(b: &mut Bencher) { pub fn bench_noncopy(b: &mut Bencher) {
let arena = TypedArena::new(); let arena = TypedArena::default();
b.iter(|| { b.iter(|| {
arena.alloc(Noncopy { arena.alloc(Noncopy {
string: "hello world".to_string(), string: "hello world".to_string(),

View file

@ -122,6 +122,6 @@ fn f<'a>(arena: &'a TypedArena<C<'a>>) {
} }
fn main() { fn main() {
let arena = TypedArena::new(); let arena = TypedArena::default();
f(&arena); f(&arena);
} //~^ ERROR `arena` does not live long enough } //~^ ERROR `arena` does not live long enough

View file

@ -47,7 +47,7 @@ impl<'a> HasId for &'a usize { fn count(&self) -> usize { 1 } }
fn f<'a>(_arena: &'a TypedArena<C<'a>>) {} fn f<'a>(_arena: &'a TypedArena<C<'a>>) {}
fn main() { fn main() {
let arena: TypedArena<C> = TypedArena::new(); let arena: TypedArena<C> = TypedArena::default();
f(&arena); f(&arena);
} //~^ ERROR `arena` does not live long enough } //~^ ERROR `arena` does not live long enough