complex: update testing imports and hash

This commit is contained in:
Josh Stone 2016-03-25 16:39:45 -07:00
parent e672d006a4
commit 8cb026e273
1 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,8 @@
extern crate num_traits as traits;
use std::fmt;
#[cfg(test)]
use std::hash;
use std::ops::{Add, Div, Mul, Neg, Sub};
#[cfg(feature = "serde")]
@ -594,6 +596,14 @@ impl<T> serde::Deserialize for Complex<T> where
}
}
#[cfg(test)]
fn hash<T: hash::Hash>(x: &T) -> u64 {
use std::hash::Hasher;
let mut hasher = hash::SipHasher::new();
x.hash(&mut hasher);
hasher.finish()
}
#[cfg(test)]
mod test {
#![allow(non_upper_case_globals)]
@ -601,7 +611,7 @@ mod test {
use super::{Complex64, Complex};
use std::f64;
use {Zero, One, Float};
use traits::{Zero, One, Float};
pub const _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
pub const _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
@ -994,7 +1004,7 @@ mod test {
mod complex_arithmetic {
use super::{_0_0i, _1_0i, _1_1i, _0_1i, _neg1_1i, _05_05i, all_consts};
use Zero;
use traits::Zero;
#[test]
fn test_add() {