Restructure test modules to avoid warnings

These warnings occurred only when running the test suite with no
features. Lots of uses had to be rescoped into newly created modules to
make it easier to separate these issues.
This commit is contained in:
Eduard Bopp 2018-01-17 16:48:47 +01:00
parent 4a926736fe
commit bba1993e58
17 changed files with 673 additions and 649 deletions

View File

@ -1,9 +1,8 @@
use std::cmp; #![cfg(feature = "arbitrary")]
use std::cmp;
use na::{DVector, DMatrix}; use na::{DVector, DMatrix};
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
/* /*
* *

View File

@ -1,8 +1,5 @@
use num::{Zero, One}; use num::{Zero, One};
use num::Float; use num::Float;
use std::fmt::Display;
use alga::linear::FiniteDimInnerSpace;
use na::{self, use na::{self,
DVector, DMatrix, DVector, DMatrix,
@ -806,10 +803,15 @@ mod normalization_tests {
} }
} }
#[cfg(feature = "arbitrary")]
// FIXME: move this to alga ? // FIXME: move this to alga ?
mod finite_dim_inner_space_tests {
use super::*;
use std::fmt::Display;
use alga::linear::FiniteDimInnerSpace;
macro_rules! finite_dim_inner_space_test( macro_rules! finite_dim_inner_space_test(
($($Vector: ident, $orthonormal_subspace: ident, $orthonormalization: ident);* $(;)*) => {$( ($($Vector: ident, $orthonormal_subspace: ident, $orthonormalization: ident);* $(;)*) => {$(
#[cfg(feature = "arbitrary")]
quickcheck!{ quickcheck!{
fn $orthonormal_subspace(vs: Vec<$Vector<f64>>) -> bool { fn $orthonormal_subspace(vs: Vec<$Vector<f64>>) -> bool {
let mut given_basis = vs.clone(); let mut given_basis = vs.clone();
@ -877,6 +879,7 @@ finite_dim_inner_space_test!(
* Helper functions. * Helper functions.
* *
*/ */
#[cfg(feature = "arbitrary")]
fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64> + Display>(vs: &[T]) -> bool { fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64> + Display>(vs: &[T]) -> bool {
for i in 0 .. vs.len() { for i in 0 .. vs.len() {
// Basis elements must be normalized. // Basis elements must be normalized.
@ -896,3 +899,4 @@ fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64> + Display>(vs: &[T]) ->
true true
} }
}

View File

@ -1,4 +1,4 @@
use na::{Point3, Perspective3, Orthographic3}; use na::{Perspective3, Orthographic3};
#[test] #[test]
fn perspective_inverse() { fn perspective_inverse() {
@ -22,6 +22,9 @@ fn orthographic_inverse() {
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use na::{Point3, Perspective3, Orthographic3};
quickcheck!{ quickcheck!{
fn perspective_project_unproject(pt: Point3<f64>) -> bool { fn perspective_project_unproject(pt: Point3<f64>) -> bool {
let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0); let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
@ -41,3 +44,4 @@ quickcheck!{
relative_eq!(pt, unprojected, epsilon = 1.0e-7) relative_eq!(pt, unprojected, epsilon = 1.0e-7)
} }
} }
}

View File

@ -1,6 +1,4 @@
use std::f64; use na::{Vector2, Vector3};
use alga::general::Real;
use na::{self, Vector2, Vector3, Rotation2, Rotation3, Unit};
#[test] #[test]
fn angle_2() { fn angle_2() {
@ -19,7 +17,12 @@ fn angle_3() {
} }
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
quickcheck!( mod quickcheck_tests {
use std::f64;
use alga::general::Real;
use na::{self, Vector2, Vector3, Rotation2, Rotation3, Unit};
quickcheck! {
/* /*
* *
* Euler angles. * Euler angles.
@ -202,4 +205,5 @@ quickcheck!(
r == Rotation3::identity() r == Rotation3::identity()
} }
} }
); }
}

View File

@ -1,9 +1,9 @@
#![cfg(feature = "arbitrary")]
#![allow(non_snake_case)] #![allow(non_snake_case)]
use alga::linear::{Transformation, ProjectiveTransformation}; use alga::linear::{Transformation, ProjectiveTransformation};
use na::{Vector3, Point3, Similarity3, Translation3, Isometry3, UnitQuaternion}; use na::{Vector3, Point3, Similarity3, Translation3, Isometry3, UnitQuaternion};
#[cfg(feature = "arbitrary")]
quickcheck!( quickcheck!(
fn inverse_is_identity(i: Similarity3<f64>, p: Point3<f64>, v: Vector3<f64>) -> bool { fn inverse_is_identity(i: Similarity3<f64>, p: Point3<f64>, v: Vector3<f64>) -> bool {
let ii = i.inverse(); let ii = i.inverse();

View File

@ -1,9 +1,8 @@
#![cfg(feature = "arbitrary")]
#![allow(non_snake_case)] #![allow(non_snake_case)]
use na::{Unit, UnitComplex, Vector2, Point2, Rotation2}; use na::{Unit, UnitComplex, Vector2, Point2, Rotation2};
#[cfg(feature = "arbitrary")]
quickcheck!( quickcheck!(
/* /*

View File

@ -1,9 +1,10 @@
#![cfg(feature = "arbitrary")]
use std::cmp; use std::cmp;
use na::{DMatrix, Matrix4}; use na::{DMatrix, Matrix4};
use na::balancing; use na::balancing;
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
fn balancing_parlett_reinsch(n: usize) -> bool { fn balancing_parlett_reinsch(n: usize) -> bool {
let n = cmp::min(n, 10); let n = cmp::min(n, 10);

View File

@ -1,7 +1,7 @@
#![cfg(feature = "arbitrary")]
use na::{DMatrix, Matrix2, Matrix4, Matrix5x3, Matrix3x5}; use na::{DMatrix, Matrix2, Matrix4, Matrix5x3, Matrix3x5};
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
fn bidiagonal(m: DMatrix<f64>) -> bool { fn bidiagonal(m: DMatrix<f64>) -> bool {
if m.len() == 0 { if m.len() == 0 {

View File

@ -1,8 +1,10 @@
use std::cmp; use na::DMatrix;
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use std::cmp;
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
quickcheck! { quickcheck! {
fn symmetric_eigen(n: usize) -> bool { fn symmetric_eigen(n: usize) -> bool {
let n = cmp::max(1, cmp::min(n, 10)); let n = cmp::max(1, cmp::min(n, 10));
@ -55,6 +57,7 @@ quickcheck! {
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5) relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)
} }
} }
}
// Test proposed on the issue #176 of rulinalg. // Test proposed on the issue #176 of rulinalg.
#[test] #[test]

View File

@ -1,7 +1,4 @@
use std::cmp; use na::Matrix3;
use na::{DMatrix, Matrix3, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5,
DVector, Vector4};
#[test] #[test]
fn full_piv_lu_simple() { fn full_piv_lu_simple() {
@ -42,6 +39,10 @@ fn full_piv_lu_simple_with_pivot() {
} }
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use std::cmp;
use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5, DVector, Vector4};
quickcheck! { quickcheck! {
fn full_piv_lu(m: DMatrix<f64>) -> bool { fn full_piv_lu(m: DMatrix<f64>) -> bool {
let mut m = m; let mut m = m;
@ -153,3 +154,4 @@ quickcheck! {
} }
} }
} }
}

View File

@ -1,7 +1,8 @@
#![cfg(feature = "arbitrary")]
use std::cmp; use std::cmp;
use na::{DMatrix, Matrix2, Matrix4}; use na::{DMatrix, Matrix2, Matrix4};
#[test] #[test]
fn hessenberg_simple() { fn hessenberg_simple() {
let m = Matrix2::new(1.0, 0.0, let m = Matrix2::new(1.0, 0.0,
@ -11,8 +12,6 @@ fn hessenberg_simple() {
assert!(relative_eq!(m, p * h * p.transpose(), epsilon = 1.0e-7)) assert!(relative_eq!(m, p * h * p.transpose(), epsilon = 1.0e-7))
} }
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
fn hessenberg(n: usize) -> bool { fn hessenberg(n: usize) -> bool {
let n = cmp::max(1, cmp::min(n, 50)); let n = cmp::max(1, cmp::min(n, 50));

View File

@ -1,7 +1,4 @@
use std::cmp; use na::Matrix3;
use na::{DMatrix, Matrix3, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5,
DVector, Vector4};
#[test] #[test]
fn lu_simple() { fn lu_simple() {
@ -40,6 +37,10 @@ fn lu_simple_with_pivot() {
} }
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use std::cmp;
use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5, DVector, Vector4};
quickcheck! { quickcheck! {
fn lu(m: DMatrix<f64>) -> bool { fn lu(m: DMatrix<f64>) -> bool {
let mut m = m; let mut m = m;
@ -147,3 +148,4 @@ quickcheck! {
} }
} }
} }
}

View File

@ -1,8 +1,9 @@
#![cfg(feature = "arbitrary")]
use std::cmp; use std::cmp;
use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5, use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5,
DVector, Vector4}; DVector, Vector4};
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
fn qr(m: DMatrix<f64>) -> bool { fn qr(m: DMatrix<f64>) -> bool {
let qr = m.clone().qr(); let qr = m.clone().qr();

View File

@ -1,5 +1,4 @@
use std::cmp; use na::{DMatrix, Matrix3, Matrix4};
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
#[test] #[test]
@ -15,6 +14,10 @@ fn schur_simpl_mat3() {
} }
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use std::cmp;
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
quickcheck! { quickcheck! {
fn schur(n: usize) -> bool { fn schur(n: usize) -> bool {
let n = cmp::max(1, cmp::min(n, 10)); let n = cmp::max(1, cmp::min(n, 10));
@ -60,6 +63,7 @@ quickcheck! {
ok ok
} }
} }
}
#[test] #[test]
fn schur_static_mat4_fail() { fn schur_static_mat4_fail() {

View File

@ -1,3 +1,5 @@
#![cfg(feature = "arbitrary")]
use na::{Matrix4, Matrix4x5}; use na::{Matrix4, Matrix4x5};
fn unzero_diagonal(a: &mut Matrix4<f64>) { fn unzero_diagonal(a: &mut Matrix4<f64>) {
@ -8,7 +10,6 @@ fn unzero_diagonal(a: &mut Matrix4<f64>) {
} }
} }
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
fn solve_lower_triangular(a: Matrix4<f64>, b: Matrix4x5<f64>) -> bool { fn solve_lower_triangular(a: Matrix4<f64>, b: Matrix4x5<f64>) -> bool {
let mut a = a; let mut a = a;

View File

@ -1,10 +1,10 @@
use std::cmp; use na::{DMatrix, Matrix6};
use na::{DMatrix, Matrix2, Matrix3, Matrix4, Matrix6, Matrix5x2, Matrix5x3, Matrix2x5, Matrix3x5,
DVector};
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use std::cmp;
use na::{DMatrix, Matrix2, Matrix3, Matrix4, Matrix5x2, Matrix5x3, Matrix2x5, Matrix3x5, DVector};
quickcheck! { quickcheck! {
fn svd(m: DMatrix<f64>) -> bool { fn svd(m: DMatrix<f64>) -> bool {
if m.len() > 0 { if m.len() > 0 {
@ -138,6 +138,7 @@ quickcheck! {
true true
} }
} }
}
// Test proposed on the issue #176 of rulinalg. // Test proposed on the issue #176 of rulinalg.
#[test] #[test]

View File

@ -1,9 +1,9 @@
#![cfg(feature = "arbitrary")]
use std::cmp; use std::cmp;
use na::{DMatrix, Matrix2, Matrix4}; use na::{DMatrix, Matrix2, Matrix4};
#[cfg(feature = "arbitrary")]
quickcheck! { quickcheck! {
fn symm_tridiagonal(n: usize) -> bool { fn symm_tridiagonal(n: usize) -> bool {
let n = cmp::max(1, cmp::min(n, 50)); let n = cmp::max(1, cmp::min(n, 50));