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};
#[cfg(feature = "arbitrary")]
quickcheck! {
/*
*

View File

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

View File

@ -1,4 +1,4 @@
use na::{Point3, Perspective3, Orthographic3};
use na::{Perspective3, Orthographic3};
#[test]
fn perspective_inverse() {
@ -22,6 +22,9 @@ fn orthographic_inverse() {
#[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use na::{Point3, Perspective3, Orthographic3};
quickcheck!{
fn perspective_project_unproject(pt: Point3<f64>) -> bool {
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)
}
}
}

View File

@ -1,6 +1,4 @@
use std::f64;
use alga::general::Real;
use na::{self, Vector2, Vector3, Rotation2, Rotation3, Unit};
use na::{Vector2, Vector3};
#[test]
fn angle_2() {
@ -19,7 +17,12 @@ fn angle_3() {
}
#[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.
@ -202,4 +205,5 @@ quickcheck!(
r == Rotation3::identity()
}
}
);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,10 @@
use std::cmp;
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
use na::DMatrix;
#[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use std::cmp;
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
quickcheck! {
fn symmetric_eigen(n: usize) -> bool {
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)
}
}
}
// Test proposed on the issue #176 of rulinalg.
#[test]

View File

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

View File

@ -1,7 +1,8 @@
#![cfg(feature = "arbitrary")]
use std::cmp;
use na::{DMatrix, Matrix2, Matrix4};
#[test]
fn hessenberg_simple() {
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))
}
#[cfg(feature = "arbitrary")]
quickcheck! {
fn hessenberg(n: usize) -> bool {
let n = cmp::max(1, cmp::min(n, 50));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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