Fix `non_uppercase_statics` warnings of private constants.

This commit is contained in:
gifnksm 2014-10-10 22:54:30 +09:00
parent 2fe050c471
commit ac37b913d9
2 changed files with 80 additions and 80 deletions

View File

@ -87,12 +87,12 @@ pub mod BigDigit {
pub const bits: uint = 32;
pub const base: DoubleBigDigit = 1 << bits;
const lo_mask: DoubleBigDigit = (-1 as DoubleBigDigit) >> bits;
const LO_MASK: DoubleBigDigit = (-1 as DoubleBigDigit) >> bits;
#[inline]
fn get_hi(n: DoubleBigDigit) -> BigDigit { (n >> bits) as BigDigit }
#[inline]
fn get_lo(n: DoubleBigDigit) -> BigDigit { (n & lo_mask) as BigDigit }
fn get_lo(n: DoubleBigDigit) -> BigDigit { (n & LO_MASK) as BigDigit }
/// Split one `DoubleBigDigit` into two `BigDigit`s.
#[inline]
@ -1839,9 +1839,9 @@ mod biguint_tests {
BigInt::from_biguint(Plus, BigUint::new(vec!(1,2,3))));
}
static sum_triples: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
const SUM_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
(&[], &[ 1], &[ 1]),
(&[ 1], &[ 1], &[ 2]),
@ -1855,7 +1855,7 @@ mod biguint_tests {
#[test]
fn test_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1868,7 +1868,7 @@ mod biguint_tests {
#[test]
fn test_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1886,9 +1886,9 @@ mod biguint_tests {
a - b;
}
static mul_triples: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
const MUL_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
(&[], &[ 1], &[]),
(&[ 2], &[], &[]),
@ -1912,10 +1912,10 @@ mod biguint_tests {
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
];
static div_rem_quadruples: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])]
const DIV_REM_QUADRUPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])]
= &[
(&[ 1], &[ 2], &[], &[1]),
(&[ 1, 1], &[ 2], &[-1/2+1], &[1]),
@ -1926,7 +1926,7 @@ mod biguint_tests {
#[test]
fn test_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1936,7 +1936,7 @@ mod biguint_tests {
assert!(b * a == c);
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1950,7 +1950,7 @@ mod biguint_tests {
#[test]
fn test_div_rem() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1964,7 +1964,7 @@ mod biguint_tests {
}
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1977,7 +1977,7 @@ mod biguint_tests {
#[test]
fn test_checked_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -1990,7 +1990,7 @@ mod biguint_tests {
#[test]
fn test_checked_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -2010,7 +2010,7 @@ mod biguint_tests {
#[test]
fn test_checked_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -2020,7 +2020,7 @@ mod biguint_tests {
assert!(b.checked_mul(&a).unwrap() == c);
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -2034,7 +2034,7 @@ mod biguint_tests {
#[test]
fn test_checked_div() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
@ -2438,9 +2438,9 @@ mod bigint_tests {
assert_eq!(negative.to_biguint(), None);
}
static sum_triples: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
const SUM_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
(&[], &[ 1], &[ 1]),
(&[ 1], &[ 1], &[ 2]),
@ -2454,7 +2454,7 @@ mod bigint_tests {
#[test]
fn test_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2473,7 +2473,7 @@ mod bigint_tests {
#[test]
fn test_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2490,7 +2490,7 @@ mod bigint_tests {
}
}
static mul_triples: &'static [(&'static [BigDigit],
static MUL_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
@ -2516,7 +2516,7 @@ mod bigint_tests {
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
];
static div_rem_quadruples: &'static [(&'static [BigDigit],
static DIV_REM_QUADRUPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])]
@ -2530,7 +2530,7 @@ mod bigint_tests {
#[test]
fn test_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2543,7 +2543,7 @@ mod bigint_tests {
assert!((-b) * a == -c);
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2582,7 +2582,7 @@ mod bigint_tests {
}
}
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2592,7 +2592,7 @@ mod bigint_tests {
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2625,7 +2625,7 @@ mod bigint_tests {
check_sub(&a.neg(), b, &q.neg(), &r.neg());
check_sub(&a.neg(), &b.neg(), q, &r.neg());
}
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2635,7 +2635,7 @@ mod bigint_tests {
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2650,7 +2650,7 @@ mod bigint_tests {
#[test]
fn test_checked_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2669,7 +2669,7 @@ mod bigint_tests {
#[test]
fn test_checked_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2688,7 +2688,7 @@ mod bigint_tests {
#[test]
fn test_checked_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2701,7 +2701,7 @@ mod bigint_tests {
assert!((-b).checked_mul(&a).unwrap() == -c);
}
for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
@ -2714,7 +2714,7 @@ mod bigint_tests {
}
#[test]
fn test_checked_div() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);

View File

@ -406,11 +406,11 @@ mod test {
pub const _2: Rational = Ratio { numer: 2, denom: 1};
pub const _1_2: Rational = Ratio { numer: 1, denom: 2};
pub const _3_2: Rational = Ratio { numer: 3, denom: 2};
pub const _neg1_2: Rational = Ratio { numer: -1, denom: 2};
pub const _NEG1_2: Rational = Ratio { numer: -1, denom: 2};
pub const _1_3: Rational = Ratio { numer: 1, denom: 3};
pub const _neg1_3: Rational = Ratio { numer: -1, denom: 3};
pub const _NEG1_3: Rational = Ratio { numer: -1, denom: 3};
pub const _2_3: Rational = Ratio { numer: 2, denom: 3};
pub const _neg2_3: Rational = Ratio { numer: -2, denom: 3};
pub const _NEG2_3: Rational = Ratio { numer: -2, denom: 3};
pub fn to_big(n: Rational) -> BigRational {
Ratio::new(
@ -427,7 +427,7 @@ mod test {
assert_eq!(_2, Ratio::from_integer(2i));
assert_eq!(_1_2, Ratio::new(1i,2i));
assert_eq!(_3_2, Ratio::new(3i,2i));
assert_eq!(_neg1_2, Ratio::new(-1i,2i));
assert_eq!(_NEG1_2, Ratio::new(-1i,2i));
}
#[test]
@ -465,7 +465,7 @@ mod test {
assert_eq!(_2.to_integer(), 2);
assert_eq!(_1_2.to_integer(), 0);
assert_eq!(_3_2.to_integer(), 1);
assert_eq!(_neg1_2.to_integer(), 0);
assert_eq!(_NEG1_2.to_integer(), 0);
}
@ -476,7 +476,7 @@ mod test {
assert_eq!(_2.numer(), &2);
assert_eq!(_1_2.numer(), &1);
assert_eq!(_3_2.numer(), &3);
assert_eq!(_neg1_2.numer(), &(-1));
assert_eq!(_NEG1_2.numer(), &(-1));
}
#[test]
fn test_denom() {
@ -485,7 +485,7 @@ mod test {
assert_eq!(_2.denom(), &1);
assert_eq!(_1_2.denom(), &2);
assert_eq!(_3_2.denom(), &2);
assert_eq!(_neg1_2.denom(), &2);
assert_eq!(_NEG1_2.denom(), &2);
}
@ -496,7 +496,7 @@ mod test {
assert!(_2.is_integer());
assert!(!_1_2.is_integer());
assert!(!_3_2.is_integer());
assert!(!_neg1_2.is_integer());
assert!(!_NEG1_2.is_integer());
}
#[test]
@ -508,7 +508,7 @@ mod test {
}
mod arith {
use super::{_0, _1, _2, _1_2, _3_2, _neg1_2, to_big};
use super::{_0, _1, _2, _1_2, _3_2, _NEG1_2, to_big};
use super::super::{Ratio, Rational};
#[test]
@ -521,7 +521,7 @@ mod test {
test(_1, _1_2, _3_2);
test(_1, _1, _2);
test(_1_2, _3_2, _2);
test(_1_2, _neg1_2, _0);
test(_1_2, _NEG1_2, _0);
}
#[test]
@ -533,7 +533,7 @@ mod test {
test(_1, _1_2, _1_2);
test(_3_2, _1_2, _1);
test(_1, _neg1_2, _3_2);
test(_1, _NEG1_2, _3_2);
}
#[test]
@ -545,7 +545,7 @@ mod test {
test(_1, _1_2, _1_2);
test(_1_2, _3_2, Ratio::new(3i,4i));
test(_1_2, _neg1_2, Ratio::new(-1i, 4i));
test(_1_2, _NEG1_2, Ratio::new(-1i, 4i));
}
#[test]
@ -557,7 +557,7 @@ mod test {
test(_1, _1_2, _2);
test(_3_2, _1_2, _1 + _2);
test(_1, _neg1_2, _neg1_2 + _neg1_2 + _neg1_2 + _neg1_2);
test(_1, _NEG1_2, _NEG1_2 + _NEG1_2 + _NEG1_2 + _NEG1_2);
}
#[test]
@ -568,7 +568,7 @@ mod test {
}
test(_3_2, _1, _1_2);
test(_2, _neg1_2, _0);
test(_2, _NEG1_2, _0);
test(_1_2, _2, _1_2);
}
@ -580,7 +580,7 @@ mod test {
}
test(_0, _0);
test(_1_2, _neg1_2);
test(_1_2, _NEG1_2);
test(-_1, _1);
}
#[test]
@ -588,7 +588,7 @@ mod test {
assert_eq!(_0 + _0, _0);
assert_eq!(_0 * _0, _0);
assert_eq!(_0 * _1, _0);
assert_eq!(_0 / _neg1_2, _0);
assert_eq!(_0 / _NEG1_2, _0);
assert_eq!(_0 - _0, _0);
}
#[test]
@ -605,30 +605,30 @@ mod test {
assert_eq!(_1_3.round(), _0);
assert_eq!(_1_3.trunc(), _0);
assert_eq!(_neg1_3.ceil(), _0);
assert_eq!(_neg1_3.floor(), -_1);
assert_eq!(_neg1_3.round(), _0);
assert_eq!(_neg1_3.trunc(), _0);
assert_eq!(_NEG1_3.ceil(), _0);
assert_eq!(_NEG1_3.floor(), -_1);
assert_eq!(_NEG1_3.round(), _0);
assert_eq!(_NEG1_3.trunc(), _0);
assert_eq!(_2_3.ceil(), _1);
assert_eq!(_2_3.floor(), _0);
assert_eq!(_2_3.round(), _1);
assert_eq!(_2_3.trunc(), _0);
assert_eq!(_neg2_3.ceil(), _0);
assert_eq!(_neg2_3.floor(), -_1);
assert_eq!(_neg2_3.round(), -_1);
assert_eq!(_neg2_3.trunc(), _0);
assert_eq!(_NEG2_3.ceil(), _0);
assert_eq!(_NEG2_3.floor(), -_1);
assert_eq!(_NEG2_3.round(), -_1);
assert_eq!(_NEG2_3.trunc(), _0);
assert_eq!(_1_2.ceil(), _1);
assert_eq!(_1_2.floor(), _0);
assert_eq!(_1_2.round(), _1);
assert_eq!(_1_2.trunc(), _0);
assert_eq!(_neg1_2.ceil(), _0);
assert_eq!(_neg1_2.floor(), -_1);
assert_eq!(_neg1_2.round(), -_1);
assert_eq!(_neg1_2.trunc(), _0);
assert_eq!(_NEG1_2.ceil(), _0);
assert_eq!(_NEG1_2.floor(), -_1);
assert_eq!(_NEG1_2.round(), -_1);
assert_eq!(_NEG1_2.trunc(), _0);
assert_eq!(_1.ceil(), _1);
assert_eq!(_1.floor(), _1);
@ -660,7 +660,7 @@ mod test {
#[test]
fn test_fract() {
assert_eq!(_1.fract(), _0);
assert_eq!(_neg1_2.fract(), _neg1_2);
assert_eq!(_NEG1_2.fract(), _NEG1_2);
assert_eq!(_1_2.fract(), _1_2);
assert_eq!(_3_2.fract(), _1_2);
}
@ -671,7 +671,7 @@ mod test {
assert_eq!(_2 * _2.recip(), _1);
assert_eq!(_1_2 * _1_2.recip(), _1);
assert_eq!(_3_2 * _3_2.recip(), _1);
assert_eq!(_neg1_2 * _neg1_2.recip(), _1);
assert_eq!(_NEG1_2 * _NEG1_2.recip(), _1);
}
#[test]
@ -685,7 +685,7 @@ mod test {
test(_1_2, "1/2".to_string());
test(_3_2, "3/2".to_string());
test(_2, "2".to_string());
test(_neg1_2, "-1/2".to_string());
test(_NEG1_2, "-1/2".to_string());
}
#[test]
fn test_from_str_fail() {
@ -715,16 +715,16 @@ mod test {
test3(_1_2, "1/2".to_string());
test3(_3_2, "10/2".to_string());
test3(_2, "2/1".to_string());
test3(_neg1_2, "-1/2".to_string());
test3(_neg1_2 / _2, "-1/11".to_string());
test3(_NEG1_2, "-1/2".to_string());
test3(_NEG1_2 / _2, "-1/11".to_string());
test16(_1, "1/1".to_string());
test16(_0, "0/1".to_string());
test16(_1_2, "1/2".to_string());
test16(_3_2, "3/2".to_string());
test16(_2, "2/1".to_string());
test16(_neg1_2, "-1/2".to_string());
test16(_neg1_2 / _2, "-1/4".to_string());
test16(_NEG1_2, "-1/2".to_string());
test16(_NEG1_2 / _2, "-1/4".to_string());
test16(Ratio::new(13i,15i), "d/f".to_string());
test16(_1_2*_1_2*_1_2*_1_2, "1/10".to_string());
}
@ -782,13 +782,13 @@ mod test {
#[test]
fn test_signed() {
assert_eq!(_neg1_2.abs(), _1_2);
assert_eq!(_NEG1_2.abs(), _1_2);
assert_eq!(_3_2.abs_sub(&_1_2), _1);
assert_eq!(_1_2.abs_sub(&_3_2), Zero::zero());
assert_eq!(_1_2.signum(), One::one());
assert_eq!(_neg1_2.signum(), - num::one::<Ratio<int>>());
assert!(_neg1_2.is_negative());
assert!(! _neg1_2.is_positive());
assert_eq!(_NEG1_2.signum(), - num::one::<Ratio<int>>());
assert!(_NEG1_2.is_negative());
assert!(! _NEG1_2.is_positive());
assert!(! _1_2.is_negative());
}