From ccce2f2a3f9f37a6b46390e4cf2966d345cb8dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Fri, 9 Jan 2015 22:52:44 +0100 Subject: [PATCH] Fix tests and benches. --- benches/common/macros.rs | 16 ++++++++-------- tests/assert.rs | 1 - tests/mat.rs | 10 +++++----- tests/quat.rs | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/benches/common/macros.rs b/benches/common/macros.rs index 06923a74..39eb7118 100644 --- a/benches/common/macros.rs +++ b/benches/common/macros.rs @@ -8,8 +8,8 @@ macro_rules! bench_binop( let mut rng = IsaacRng::new_unseeded(); - let elems1 = Vec::from_fn(LEN, |_| rng.gen::<$t1>()); - let elems2 = Vec::from_fn(LEN, |_| rng.gen::<$t2>()); + let elems1: Vec<$t1> = (0us .. LEN).map(|_| rng.gen::<$t1>()).collect(); + let elems2: Vec<$t2> = (0us .. LEN).map(|_| rng.gen::<$t2>()).collect(); let mut i = 0; bh.iter(|| { @@ -31,8 +31,8 @@ macro_rules! bench_binop_na( let mut rng = IsaacRng::new_unseeded(); - let elems1 = Vec::from_fn(LEN, |_| rng.gen::<$t1>()); - let elems2 = Vec::from_fn(LEN, |_| rng.gen::<$t2>()); + let elems1: Vec<$t1> = (0us .. LEN).map(|_| rng.gen::<$t1>()).collect(); + let elems2: Vec<$t2> = (0us .. LEN).map(|_| rng.gen::<$t2>()).collect(); let mut i = 0; bh.iter(|| { @@ -54,7 +54,7 @@ macro_rules! bench_unop( let mut rng = IsaacRng::new_unseeded(); - let elems = Vec::from_fn(LEN, |_| rng.gen::<$t>()); + let elems: Vec<$t> = (0us .. LEN).map(|_| rng.gen::<$t>()).collect(); let mut i = 0; bh.iter(|| { @@ -76,7 +76,7 @@ macro_rules! bench_unop_self( let mut rng = IsaacRng::new_unseeded(); - let mut elems = Vec::from_fn(LEN, |_| rng.gen::<$t>()); + let mut elems: Vec<$t> = (0us .. LEN).map(|_| rng.gen::<$t>()).collect(); let mut i = 0; bh.iter(|| { @@ -91,14 +91,14 @@ macro_rules! bench_unop_self( ); macro_rules! bench_construction( - ($name: ident, $constructor: path $(, $args: ident: $types: ty)*) => { + ($name: ident, $constructor: path, $( $args: ident: $types: ty),*) => { #[bench] fn $name(bh: &mut Bencher) { const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); - $(let $args = Vec::from_fn(LEN, |_| rng.gen::<$types>());)* + $(let $args: Vec<$types> = (0us .. LEN).map(|_| rng.gen::<$types>()).collect();)* let mut i = 0; bh.iter(|| { diff --git a/tests/assert.rs b/tests/assert.rs index 6c7b0f49..0b0ebcee 100644 --- a/tests/assert.rs +++ b/tests/assert.rs @@ -1,7 +1,6 @@ //! Assertion macro tests #![feature(plugin)] -#![allow(unstable)] #[plugin] #[macro_use] diff --git a/tests/mat.rs b/tests/mat.rs index c67e6985..a38adf7c 100644 --- a/tests/mat.rs +++ b/tests/mat.rs @@ -54,9 +54,9 @@ macro_rules! test_qr_impl( // // let recomp = eigenvectors * diag * na::transpose(&eigenvectors); // -// prisizeln!("eigenvalues: {}", eigenvalues); -// prisizeln!(" mat: {}", randmat); -// prisizeln!("recomp: {}", recomp); +// println!("eigenvalues: {}", eigenvalues); +// println!(" mat: {}", randmat); +// println!("recomp: {}", recomp); // // assert!(na::approx_eq_eps(&randmat, &recomp, &1.0e-2)); // } @@ -200,7 +200,7 @@ fn test_transpose_dmat() { 8, 4, &[ - 1us32,2, 3, 4, + 1u32,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -242,7 +242,7 @@ fn test_dmat_from_vec() { ] ); - prisizeln!("mat1: {:?}, mat2: {:?}", mat1, mat2); + println!("mat1: {:?}, mat2: {:?}", mat1, mat2); assert!(mat1 == mat2); } diff --git a/tests/quat.rs b/tests/quat.rs index c9f76b30..2b1d9532 100644 --- a/tests/quat.rs +++ b/tests/quat.rs @@ -52,7 +52,7 @@ fn test_quat_to_axis_angle() { let q = UnitQuat::new(axis_angle); - prisizeln!("{:?} {:?}", q.rotation(), axis_angle); + println!("{:?} {:?}", q.rotation(), axis_angle); assert!(na::approx_eq(&q.rotation(), &axis_angle)) } }