diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 38a663dc2450..337b0722ce7a 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -277,45 +277,48 @@ pub unsafe fn reserve(v: &mut @[T], n: uint) { pub unsafe fn reserve_at_least(v: &mut @[T], n: uint) { reserve(v, uint::next_power_of_two(n)); } - } -#[test] -pub fn test() { - // Some code that could use that, then: - fn seq_range(lo: uint, hi: uint) -> @[uint] { - do build |push| { - for uint::range(lo, hi) |i| { - push(i); +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test() { + // Some code that could use that, then: + fn seq_range(lo: uint, hi: uint) -> @[uint] { + do build |push| { + for uint::range(lo, hi) |i| { + push(i); + } } } + + assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]); + assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]); + assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]); } - assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]); - assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]); - assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]); -} + #[test] + fn append_test() { + assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]); + } -#[test] -pub fn append_test() { - assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]); -} - -#[test] -pub fn test_from_owned() { - assert!(from_owned::(~[]) == @[]); - assert!(from_owned(~[true]) == @[true]); - assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]); - assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]); - assert!(from_owned(~[~[42]]) == @[~[42]]); -} - -#[test] -pub fn test_from_slice() { - assert!(from_slice::([]) == @[]); - assert!(from_slice([true]) == @[true]); - assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]); - assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]); - assert!(from_slice([@[42]]) == @[@[42]]); -} + #[test] + fn test_from_owned() { + assert!(from_owned::(~[]) == @[]); + assert!(from_owned(~[true]) == @[true]); + assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]); + assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]); + assert!(from_owned(~[~[42]]) == @[~[42]]); + } + #[test] + fn test_from_slice() { + assert!(from_slice::([]) == @[]); + assert!(from_slice([true]) == @[true]); + assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]); + assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]); + assert!(from_slice([@[42]]) == @[@[42]]); + } +} \ No newline at end of file diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 42464c848efb..1d214f402f5a 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -111,16 +111,16 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T { ****************************************************************************/ #[cfg(test)] -pub mod tests { +mod tests { use cast::{bump_box_refcount, reinterpret_cast, transmute}; #[test] - pub fn test_reinterpret_cast() { + fn test_reinterpret_cast() { assert!(1u == unsafe { reinterpret_cast(&1) }); } #[test] - pub fn test_bump_box_refcount() { + fn test_bump_box_refcount() { unsafe { let box = @~"box box box"; // refcount 1 bump_box_refcount(box); // refcount 2 @@ -135,7 +135,7 @@ pub fn test_bump_box_refcount() { } #[test] - pub fn test_transmute() { + fn test_transmute() { use managed::raw::BoxRepr; unsafe { let x = @100u8; @@ -146,7 +146,7 @@ pub fn test_transmute() { } #[test] - pub fn test_transmute2() { + fn test_transmute2() { unsafe { assert!(~[76u8, 0u8] == transmute(~"L")); } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index d665bf311f36..f8b046e5b8c4 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -426,12 +426,12 @@ pub fn try_send_one(chan: ChanOne, data: T) } #[cfg(test)] -pub mod test { +mod test { use either::Right; use super::{Chan, Port, oneshot, recv_one, stream}; #[test] - pub fn test_select2() { + fn test_select2() { let (p1, c1) = stream(); let (p2, c2) = stream(); @@ -446,7 +446,7 @@ pub fn test_select2() { } #[test] - pub fn test_oneshot() { + fn test_oneshot() { let (c, p) = oneshot::init(); oneshot::client::send(c, ()); diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index c229bc17311c..ba1f8cebdb01 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -357,170 +357,176 @@ fn reset(&self) { } } -#[test] -pub fn test_siphash() { - let vecs : [[u8, ..8], ..64] = [ - [ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ], - [ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ], - [ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ], - [ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, ], - [ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, ], - [ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, ], - [ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, ], - [ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, ], - [ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, ], - [ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, ], - [ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, ], - [ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, ], - [ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, ], - [ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, ], - [ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, ], - [ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, ], - [ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, ], - [ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, ], - [ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, ], - [ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, ], - [ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, ], - [ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, ], - [ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, ], - [ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, ], - [ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, ], - [ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, ], - [ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, ], - [ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, ], - [ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, ], - [ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, ], - [ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, ], - [ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, ], - [ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, ], - [ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, ], - [ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, ], - [ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, ], - [ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, ], - [ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, ], - [ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, ], - [ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, ], - [ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, ], - [ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, ], - [ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, ], - [ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, ], - [ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, ], - [ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, ], - [ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, ], - [ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, ], - [ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, ], - [ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, ], - [ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, ], - [ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, ], - [ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, ], - [ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, ], - [ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, ], - [ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, ], - [ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, ], - [ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, ], - [ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, ], - [ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, ], - [ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, ], - [ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, ], - [ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, ], - [ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, ] - ]; +#[cfg(test)] +mod tests { + use super::*; + use prelude::*; - let k0 = 0x_07_06_05_04_03_02_01_00_u64; - let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08_u64; - let mut buf : ~[u8] = ~[]; - let mut t = 0; - let stream_inc = &State(k0,k1); - let stream_full = &State(k0,k1); + #[test] + fn test_siphash() { + let vecs : [[u8, ..8], ..64] = [ + [ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ], + [ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ], + [ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ], + [ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, ], + [ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, ], + [ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, ], + [ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, ], + [ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, ], + [ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, ], + [ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, ], + [ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, ], + [ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, ], + [ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, ], + [ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, ], + [ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, ], + [ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, ], + [ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, ], + [ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, ], + [ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, ], + [ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, ], + [ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, ], + [ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, ], + [ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, ], + [ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, ], + [ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, ], + [ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, ], + [ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, ], + [ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, ], + [ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, ], + [ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, ], + [ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, ], + [ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, ], + [ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, ], + [ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, ], + [ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, ], + [ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, ], + [ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, ], + [ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, ], + [ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, ], + [ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, ], + [ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, ], + [ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, ], + [ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, ], + [ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, ], + [ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, ], + [ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, ], + [ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, ], + [ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, ], + [ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, ], + [ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, ], + [ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, ], + [ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, ], + [ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, ], + [ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, ], + [ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, ], + [ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, ], + [ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, ], + [ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, ], + [ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, ], + [ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, ], + [ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, ], + [ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, ], + [ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, ], + [ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, ] + ]; - fn to_hex_str(r: &[u8, ..8]) -> ~str { - let mut s = ~""; - for vec::each(*r) |b| { - s += uint::to_str_radix(*b as uint, 16u); + let k0 = 0x_07_06_05_04_03_02_01_00_u64; + let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08_u64; + let mut buf : ~[u8] = ~[]; + let mut t = 0; + let stream_inc = &State(k0,k1); + let stream_full = &State(k0,k1); + + fn to_hex_str(r: &[u8, ..8]) -> ~str { + let mut s = ~""; + for vec::each(*r) |b| { + s += uint::to_str_radix(*b as uint, 16u); + } + s + } + + while t < 64 { + debug!("siphash test %?", t); + let vec = u8to64_le!(vecs[t], 0); + let out = buf.hash_keyed(k0, k1); + debug!("got %?, expected %?", out, vec); + assert!(vec == out); + + stream_full.reset(); + stream_full.input(buf); + let f = stream_full.result_str(); + let i = stream_inc.result_str(); + let v = to_hex_str(&vecs[t]); + debug!("%d: (%s) => inc=%s full=%s", t, v, i, f); + + assert!(f == i && f == v); + + buf += ~[t as u8]; + stream_inc.input(~[t as u8]); + + t += 1; } - s } - while t < 64 { - debug!("siphash test %?", t); - let vec = u8to64_le!(vecs[t], 0); - let out = buf.hash_keyed(k0, k1); - debug!("got %?, expected %?", out, vec); - assert!(vec == out); - - stream_full.reset(); - stream_full.input(buf); - let f = stream_full.result_str(); - let i = stream_inc.result_str(); - let v = to_hex_str(&vecs[t]); - debug!("%d: (%s) => inc=%s full=%s", t, v, i, f); - - assert!(f == i && f == v); - - buf += ~[t as u8]; - stream_inc.input(~[t as u8]); - - t += 1; + #[test] #[cfg(target_arch = "arm")] + fn test_hash_uint() { + let val = 0xdeadbeef_deadbeef_u64; + assert!((val as u64).hash() != (val as uint).hash()); + assert!((val as u32).hash() == (val as uint).hash()); } -} - -#[test] #[cfg(target_arch = "arm")] -pub fn test_hash_uint() { - let val = 0xdeadbeef_deadbeef_u64; - assert!((val as u64).hash() != (val as uint).hash()); - assert!((val as u32).hash() == (val as uint).hash()); -} -#[test] #[cfg(target_arch = "x86_64")] -pub fn test_hash_uint() { - let val = 0xdeadbeef_deadbeef_u64; - assert!((val as u64).hash() == (val as uint).hash()); - assert!((val as u32).hash() != (val as uint).hash()); -} -#[test] #[cfg(target_arch = "x86")] -pub fn test_hash_uint() { - let val = 0xdeadbeef_deadbeef_u64; - assert!((val as u64).hash() != (val as uint).hash()); - assert!((val as u32).hash() == (val as uint).hash()); -} - -#[test] -pub fn test_hash_idempotent() { - let val64 = 0xdeadbeef_deadbeef_u64; - val64.hash() == val64.hash(); - let val32 = 0xdeadbeef_u32; - val32.hash() == val32.hash(); -} - -#[test] -pub fn test_hash_no_bytes_dropped_64() { - let val = 0xdeadbeef_deadbeef_u64; - - assert!(val.hash() != zero_byte(val, 0).hash()); - assert!(val.hash() != zero_byte(val, 1).hash()); - assert!(val.hash() != zero_byte(val, 2).hash()); - assert!(val.hash() != zero_byte(val, 3).hash()); - assert!(val.hash() != zero_byte(val, 4).hash()); - assert!(val.hash() != zero_byte(val, 5).hash()); - assert!(val.hash() != zero_byte(val, 6).hash()); - assert!(val.hash() != zero_byte(val, 7).hash()); - - fn zero_byte(val: u64, byte: uint) -> u64 { - assert!(byte < 8); - val & !(0xff << (byte * 8)) + #[test] #[cfg(target_arch = "x86_64")] + fn test_hash_uint() { + let val = 0xdeadbeef_deadbeef_u64; + assert!((val as u64).hash() == (val as uint).hash()); + assert!((val as u32).hash() != (val as uint).hash()); } -} - -#[test] -pub fn test_hash_no_bytes_dropped_32() { - let val = 0xdeadbeef_u32; - - assert!(val.hash() != zero_byte(val, 0).hash()); - assert!(val.hash() != zero_byte(val, 1).hash()); - assert!(val.hash() != zero_byte(val, 2).hash()); - assert!(val.hash() != zero_byte(val, 3).hash()); - - fn zero_byte(val: u32, byte: uint) -> u32 { - assert!(byte < 4); - val & !(0xff << (byte * 8)) + #[test] #[cfg(target_arch = "x86")] + fn test_hash_uint() { + let val = 0xdeadbeef_deadbeef_u64; + assert!((val as u64).hash() != (val as uint).hash()); + assert!((val as u32).hash() == (val as uint).hash()); } -} + + #[test] + fn test_hash_idempotent() { + let val64 = 0xdeadbeef_deadbeef_u64; + val64.hash() == val64.hash(); + let val32 = 0xdeadbeef_u32; + val32.hash() == val32.hash(); + } + + #[test] + fn test_hash_no_bytes_dropped_64() { + let val = 0xdeadbeef_deadbeef_u64; + + assert!(val.hash() != zero_byte(val, 0).hash()); + assert!(val.hash() != zero_byte(val, 1).hash()); + assert!(val.hash() != zero_byte(val, 2).hash()); + assert!(val.hash() != zero_byte(val, 3).hash()); + assert!(val.hash() != zero_byte(val, 4).hash()); + assert!(val.hash() != zero_byte(val, 5).hash()); + assert!(val.hash() != zero_byte(val, 6).hash()); + assert!(val.hash() != zero_byte(val, 7).hash()); + + fn zero_byte(val: u64, byte: uint) -> u64 { + assert!(byte < 8); + val & !(0xff << (byte * 8)) + } + } + + #[test] + fn test_hash_no_bytes_dropped_32() { + let val = 0xdeadbeef_u32; + + assert!(val.hash() != zero_byte(val, 0).hash()); + assert!(val.hash() != zero_byte(val, 1).hash()); + assert!(val.hash() != zero_byte(val, 2).hash()); + assert!(val.hash() != zero_byte(val, 3).hash()); + + fn zero_byte(val: u32, byte: uint) -> u32 { + assert!(byte < 4); + val & !(0xff << (byte * 8)) + } + } +} \ No newline at end of file diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 2869c198ca2f..3efe21fc42cd 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -847,7 +847,7 @@ mod test_map { use uint; #[test] - pub fn test_insert() { + fn test_insert() { let mut m = HashMap::new(); assert!(m.insert(1, 2)); assert!(m.insert(2, 4)); @@ -869,7 +869,7 @@ fn test_find_mut() { } #[test] - pub fn test_insert_overwrite() { + fn test_insert_overwrite() { let mut m = HashMap::new(); assert!(m.insert(1, 2)); assert!(*m.get(&1) == 2); @@ -878,7 +878,7 @@ pub fn test_insert_overwrite() { } #[test] - pub fn test_insert_conflicts() { + fn test_insert_conflicts() { let mut m = linear_map_with_capacity(4); assert!(m.insert(1, 2)); assert!(m.insert(5, 3)); @@ -889,7 +889,7 @@ pub fn test_insert_conflicts() { } #[test] - pub fn test_conflict_remove() { + fn test_conflict_remove() { let mut m = linear_map_with_capacity(4); assert!(m.insert(1, 2)); assert!(m.insert(5, 3)); @@ -900,7 +900,7 @@ pub fn test_conflict_remove() { } #[test] - pub fn test_is_empty() { + fn test_is_empty() { let mut m = linear_map_with_capacity(4); assert!(m.insert(1, 2)); assert!(!m.is_empty()); @@ -909,7 +909,7 @@ pub fn test_is_empty() { } #[test] - pub fn test_pop() { + fn test_pop() { let mut m = HashMap::new(); m.insert(1, 2); assert!(m.pop(&1) == Some(2)); @@ -917,7 +917,7 @@ pub fn test_pop() { } #[test] - pub fn test_swap() { + fn test_swap() { let mut m = HashMap::new(); assert!(m.swap(1, 2) == None); assert!(m.swap(1, 3) == Some(2)); @@ -925,21 +925,21 @@ pub fn test_swap() { } #[test] - pub fn test_find_or_insert() { + fn test_find_or_insert() { let mut m = HashMap::new::(); assert!(m.find_or_insert(1, 2) == &2); assert!(m.find_or_insert(1, 3) == &2); } #[test] - pub fn test_find_or_insert_with() { + fn test_find_or_insert_with() { let mut m = HashMap::new::(); assert!(m.find_or_insert_with(1, |_| 2) == &2); assert!(m.find_or_insert_with(1, |_| 3) == &2); } #[test] - pub fn test_consume() { + fn test_consume() { let mut m = HashMap::new(); assert!(m.insert(1, 2)); assert!(m.insert(2, 3)); @@ -954,7 +954,7 @@ pub fn test_consume() { } #[test] - pub fn test_iterate() { + fn test_iterate() { let mut m = linear_map_with_capacity(4); for uint::range(0, 32) |i| { assert!(m.insert(i, i*2)); @@ -968,7 +968,7 @@ pub fn test_iterate() { } #[test] - pub fn test_find() { + fn test_find() { let mut m = HashMap::new(); assert!(m.find(&1).is_none()); m.insert(1, 2); @@ -979,7 +979,7 @@ pub fn test_find() { } #[test] - pub fn test_eq() { + fn test_eq() { let mut m1 = HashMap::new(); m1.insert(1, 2); m1.insert(2, 3); @@ -997,7 +997,7 @@ pub fn test_eq() { } #[test] - pub fn test_expand() { + fn test_expand() { let mut m = HashMap::new(); assert!(m.len() == 0); diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 87d04b05087c..488756787b5c 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -29,7 +29,6 @@ #[cfg(notest)] use cmp::{Eq, Ord}; #[cfg(notest)] use ops; -#[cfg(test)] use option::{Some, None}; pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt}; pub use f64::logarithm; @@ -142,7 +141,7 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, radix, true, strconv::SignNeg, strconv::DigAll); if special { fail!(~"number has a special value, \ - try to_str_radix_special() if those are expected") } + try to_str_radix_special() if those are expected") } r } @@ -177,12 +176,6 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str { r } -#[test] -pub fn test_to_str_exact_do_decimal() { - let s = to_str_exact(5.0, 4u); - assert!(s == ~"5.0000"); -} - /** * Converts a float to a string with a maximum number of * significant digits @@ -474,196 +467,206 @@ impl ops::Neg for float { fn neg(&self) -> float { -*self } } -#[test] -pub fn test_from_str() { - assert!(from_str(~"3") == Some(3.)); - assert!(from_str(~"3.14") == Some(3.14)); - assert!(from_str(~"+3.14") == Some(3.14)); - assert!(from_str(~"-3.14") == Some(-3.14)); - assert!(from_str(~"2.5E10") == Some(25000000000.)); - assert!(from_str(~"2.5e10") == Some(25000000000.)); - assert!(from_str(~"25000000000.E-10") == Some(2.5)); - assert!(from_str(~".") == Some(0.)); - assert!(from_str(~".e1") == Some(0.)); - assert!(from_str(~".e-1") == Some(0.)); - assert!(from_str(~"5.") == Some(5.)); - assert!(from_str(~".5") == Some(0.5)); - assert!(from_str(~"0.5") == Some(0.5)); - assert!(from_str(~"-.5") == Some(-0.5)); - assert!(from_str(~"-5") == Some(-5.)); - assert!(from_str(~"inf") == Some(infinity)); - assert!(from_str(~"+inf") == Some(infinity)); - assert!(from_str(~"-inf") == Some(neg_infinity)); - // note: NaN != NaN, hence this slightly complex test - match from_str(~"NaN") { - Some(f) => assert!(is_NaN(f)), - None => fail!() - } - // note: -0 == 0, hence these slightly more complex tests - match from_str(~"-0") { - Some(v) if is_zero(v) => assert!(is_negative(v)), - _ => fail!() - } - match from_str(~"0") { - Some(v) if is_zero(v) => assert!(is_positive(v)), - _ => fail!() - } +#[cfg(test)] +mod tests { + use super::*; + use prelude::*; + #[test] + pub fn test_to_str_exact_do_decimal() { + let s = to_str_exact(5.0, 4u); + assert!(s == ~"5.0000"); + } - assert!(from_str(~"").is_none()); - assert!(from_str(~"x").is_none()); - assert!(from_str(~" ").is_none()); - assert!(from_str(~" ").is_none()); - assert!(from_str(~"e").is_none()); - assert!(from_str(~"E").is_none()); - assert!(from_str(~"E1").is_none()); - assert!(from_str(~"1e1e1").is_none()); - assert!(from_str(~"1e1.1").is_none()); - assert!(from_str(~"1e1-1").is_none()); + #[test] + pub fn test_from_str() { + assert!(from_str(~"3") == Some(3.)); + assert!(from_str(~"3.14") == Some(3.14)); + assert!(from_str(~"+3.14") == Some(3.14)); + assert!(from_str(~"-3.14") == Some(-3.14)); + assert!(from_str(~"2.5E10") == Some(25000000000.)); + assert!(from_str(~"2.5e10") == Some(25000000000.)); + assert!(from_str(~"25000000000.E-10") == Some(2.5)); + assert!(from_str(~".") == Some(0.)); + assert!(from_str(~".e1") == Some(0.)); + assert!(from_str(~".e-1") == Some(0.)); + assert!(from_str(~"5.") == Some(5.)); + assert!(from_str(~".5") == Some(0.5)); + assert!(from_str(~"0.5") == Some(0.5)); + assert!(from_str(~"-.5") == Some(-0.5)); + assert!(from_str(~"-5") == Some(-5.)); + assert!(from_str(~"inf") == Some(infinity)); + assert!(from_str(~"+inf") == Some(infinity)); + assert!(from_str(~"-inf") == Some(neg_infinity)); + // note: NaN != NaN, hence this slightly complex test + match from_str(~"NaN") { + Some(f) => assert!(is_NaN(f)), + None => fail!() + } + // note: -0 == 0, hence these slightly more complex tests + match from_str(~"-0") { + Some(v) if is_zero(v) => assert!(is_negative(v)), + _ => fail!() + } + match from_str(~"0") { + Some(v) if is_zero(v) => assert!(is_positive(v)), + _ => fail!() + } + + assert!(from_str(~"").is_none()); + assert!(from_str(~"x").is_none()); + assert!(from_str(~" ").is_none()); + assert!(from_str(~" ").is_none()); + assert!(from_str(~"e").is_none()); + assert!(from_str(~"E").is_none()); + assert!(from_str(~"E1").is_none()); + assert!(from_str(~"1e1e1").is_none()); + assert!(from_str(~"1e1.1").is_none()); + assert!(from_str(~"1e1-1").is_none()); + } + + #[test] + pub fn test_from_str_hex() { + assert!(from_str_hex(~"a4") == Some(164.)); + assert!(from_str_hex(~"a4.fe") == Some(164.9921875)); + assert!(from_str_hex(~"-a4.fe") == Some(-164.9921875)); + assert!(from_str_hex(~"+a4.fe") == Some(164.9921875)); + assert!(from_str_hex(~"ff0P4") == Some(0xff00 as float)); + assert!(from_str_hex(~"ff0p4") == Some(0xff00 as float)); + assert!(from_str_hex(~"ff0p-4") == Some(0xff as float)); + assert!(from_str_hex(~".") == Some(0.)); + assert!(from_str_hex(~".p1") == Some(0.)); + assert!(from_str_hex(~".p-1") == Some(0.)); + assert!(from_str_hex(~"f.") == Some(15.)); + assert!(from_str_hex(~".f") == Some(0.9375)); + assert!(from_str_hex(~"0.f") == Some(0.9375)); + assert!(from_str_hex(~"-.f") == Some(-0.9375)); + assert!(from_str_hex(~"-f") == Some(-15.)); + assert!(from_str_hex(~"inf") == Some(infinity)); + assert!(from_str_hex(~"+inf") == Some(infinity)); + assert!(from_str_hex(~"-inf") == Some(neg_infinity)); + // note: NaN != NaN, hence this slightly complex test + match from_str_hex(~"NaN") { + Some(f) => assert!(is_NaN(f)), + None => fail!() + } + // note: -0 == 0, hence these slightly more complex tests + match from_str_hex(~"-0") { + Some(v) if is_zero(v) => assert!(is_negative(v)), + _ => fail!() + } + match from_str_hex(~"0") { + Some(v) if is_zero(v) => assert!(is_positive(v)), + _ => fail!() + } + assert!(from_str_hex(~"e") == Some(14.)); + assert!(from_str_hex(~"E") == Some(14.)); + assert!(from_str_hex(~"E1") == Some(225.)); + assert!(from_str_hex(~"1e1e1") == Some(123361.)); + assert!(from_str_hex(~"1e1.1") == Some(481.0625)); + + assert!(from_str_hex(~"").is_none()); + assert!(from_str_hex(~"x").is_none()); + assert!(from_str_hex(~" ").is_none()); + assert!(from_str_hex(~" ").is_none()); + assert!(from_str_hex(~"p").is_none()); + assert!(from_str_hex(~"P").is_none()); + assert!(from_str_hex(~"P1").is_none()); + assert!(from_str_hex(~"1p1p1").is_none()); + assert!(from_str_hex(~"1p1.1").is_none()); + assert!(from_str_hex(~"1p1-1").is_none()); + } + + #[test] + pub fn test_to_str_hex() { + assert!(to_str_hex(164.) == ~"a4"); + assert!(to_str_hex(164.9921875) == ~"a4.fe"); + assert!(to_str_hex(-164.9921875) == ~"-a4.fe"); + assert!(to_str_hex(0xff00 as float) == ~"ff00"); + assert!(to_str_hex(-(0xff00 as float)) == ~"-ff00"); + assert!(to_str_hex(0.) == ~"0"); + assert!(to_str_hex(15.) == ~"f"); + assert!(to_str_hex(-15.) == ~"-f"); + assert!(to_str_hex(0.9375) == ~"0.f"); + assert!(to_str_hex(-0.9375) == ~"-0.f"); + assert!(to_str_hex(infinity) == ~"inf"); + assert!(to_str_hex(neg_infinity) == ~"-inf"); + assert!(to_str_hex(NaN) == ~"NaN"); + assert!(to_str_hex(0.) == ~"0"); + assert!(to_str_hex(-0.) == ~"-0"); + } + + #[test] + pub fn test_to_str_radix() { + assert!(to_str_radix(36., 36u) == ~"10"); + assert!(to_str_radix(8.125, 2u) == ~"1000.001"); + } + + #[test] + pub fn test_from_str_radix() { + assert!(from_str_radix(~"10", 36u) == Some(36.)); + assert!(from_str_radix(~"1000.001", 2u) == Some(8.125)); + } + + #[test] + pub fn test_positive() { + assert!((is_positive(infinity))); + assert!((is_positive(1.))); + assert!((is_positive(0.))); + assert!((!is_positive(-1.))); + assert!((!is_positive(neg_infinity))); + assert!((!is_positive(1./neg_infinity))); + assert!((!is_positive(NaN))); + } + + #[test] + pub fn test_negative() { + assert!((!is_negative(infinity))); + assert!((!is_negative(1.))); + assert!((!is_negative(0.))); + assert!((is_negative(-1.))); + assert!((is_negative(neg_infinity))); + assert!((is_negative(1./neg_infinity))); + assert!((!is_negative(NaN))); + } + + #[test] + pub fn test_nonpositive() { + assert!((!is_nonpositive(infinity))); + assert!((!is_nonpositive(1.))); + assert!((!is_nonpositive(0.))); + assert!((is_nonpositive(-1.))); + assert!((is_nonpositive(neg_infinity))); + assert!((is_nonpositive(1./neg_infinity))); + assert!((!is_nonpositive(NaN))); + } + + #[test] + pub fn test_nonnegative() { + assert!((is_nonnegative(infinity))); + assert!((is_nonnegative(1.))); + assert!((is_nonnegative(0.))); + assert!((!is_nonnegative(-1.))); + assert!((!is_nonnegative(neg_infinity))); + assert!((!is_nonnegative(1./neg_infinity))); + assert!((!is_nonnegative(NaN))); + } + + #[test] + pub fn test_to_str_inf() { + assert!(to_str_digits(infinity, 10u) == ~"inf"); + assert!(to_str_digits(-infinity, 10u) == ~"-inf"); + } + + #[test] + pub fn test_round() { + assert!(round(5.8) == 6.0); + assert!(round(5.2) == 5.0); + assert!(round(3.0) == 3.0); + assert!(round(2.5) == 3.0); + assert!(round(-3.5) == -4.0); + } } -#[test] -pub fn test_from_str_hex() { - assert!(from_str_hex(~"a4") == Some(164.)); - assert!(from_str_hex(~"a4.fe") == Some(164.9921875)); - assert!(from_str_hex(~"-a4.fe") == Some(-164.9921875)); - assert!(from_str_hex(~"+a4.fe") == Some(164.9921875)); - assert!(from_str_hex(~"ff0P4") == Some(0xff00 as float)); - assert!(from_str_hex(~"ff0p4") == Some(0xff00 as float)); - assert!(from_str_hex(~"ff0p-4") == Some(0xff as float)); - assert!(from_str_hex(~".") == Some(0.)); - assert!(from_str_hex(~".p1") == Some(0.)); - assert!(from_str_hex(~".p-1") == Some(0.)); - assert!(from_str_hex(~"f.") == Some(15.)); - assert!(from_str_hex(~".f") == Some(0.9375)); - assert!(from_str_hex(~"0.f") == Some(0.9375)); - assert!(from_str_hex(~"-.f") == Some(-0.9375)); - assert!(from_str_hex(~"-f") == Some(-15.)); - assert!(from_str_hex(~"inf") == Some(infinity)); - assert!(from_str_hex(~"+inf") == Some(infinity)); - assert!(from_str_hex(~"-inf") == Some(neg_infinity)); - // note: NaN != NaN, hence this slightly complex test - match from_str_hex(~"NaN") { - Some(f) => assert!(is_NaN(f)), - None => fail!() - } - // note: -0 == 0, hence these slightly more complex tests - match from_str_hex(~"-0") { - Some(v) if is_zero(v) => assert!(is_negative(v)), - _ => fail!() - } - match from_str_hex(~"0") { - Some(v) if is_zero(v) => assert!(is_positive(v)), - _ => fail!() - } - assert!(from_str_hex(~"e") == Some(14.)); - assert!(from_str_hex(~"E") == Some(14.)); - assert!(from_str_hex(~"E1") == Some(225.)); - assert!(from_str_hex(~"1e1e1") == Some(123361.)); - assert!(from_str_hex(~"1e1.1") == Some(481.0625)); - - assert!(from_str_hex(~"").is_none()); - assert!(from_str_hex(~"x").is_none()); - assert!(from_str_hex(~" ").is_none()); - assert!(from_str_hex(~" ").is_none()); - assert!(from_str_hex(~"p").is_none()); - assert!(from_str_hex(~"P").is_none()); - assert!(from_str_hex(~"P1").is_none()); - assert!(from_str_hex(~"1p1p1").is_none()); - assert!(from_str_hex(~"1p1.1").is_none()); - assert!(from_str_hex(~"1p1-1").is_none()); -} - -#[test] -pub fn test_to_str_hex() { - assert!(to_str_hex(164.) == ~"a4"); - assert!(to_str_hex(164.9921875) == ~"a4.fe"); - assert!(to_str_hex(-164.9921875) == ~"-a4.fe"); - assert!(to_str_hex(0xff00 as float) == ~"ff00"); - assert!(to_str_hex(-(0xff00 as float)) == ~"-ff00"); - assert!(to_str_hex(0.) == ~"0"); - assert!(to_str_hex(15.) == ~"f"); - assert!(to_str_hex(-15.) == ~"-f"); - assert!(to_str_hex(0.9375) == ~"0.f"); - assert!(to_str_hex(-0.9375) == ~"-0.f"); - assert!(to_str_hex(infinity) == ~"inf"); - assert!(to_str_hex(neg_infinity) == ~"-inf"); - assert!(to_str_hex(NaN) == ~"NaN"); - assert!(to_str_hex(0.) == ~"0"); - assert!(to_str_hex(-0.) == ~"-0"); -} - -#[test] -pub fn test_to_str_radix() { - assert!(to_str_radix(36., 36u) == ~"10"); - assert!(to_str_radix(8.125, 2u) == ~"1000.001"); -} - -#[test] -pub fn test_from_str_radix() { - assert!(from_str_radix(~"10", 36u) == Some(36.)); - assert!(from_str_radix(~"1000.001", 2u) == Some(8.125)); -} - -#[test] -pub fn test_positive() { - assert!((is_positive(infinity))); - assert!((is_positive(1.))); - assert!((is_positive(0.))); - assert!((!is_positive(-1.))); - assert!((!is_positive(neg_infinity))); - assert!((!is_positive(1./neg_infinity))); - assert!((!is_positive(NaN))); -} - -#[test] -pub fn test_negative() { - assert!((!is_negative(infinity))); - assert!((!is_negative(1.))); - assert!((!is_negative(0.))); - assert!((is_negative(-1.))); - assert!((is_negative(neg_infinity))); - assert!((is_negative(1./neg_infinity))); - assert!((!is_negative(NaN))); -} - -#[test] -pub fn test_nonpositive() { - assert!((!is_nonpositive(infinity))); - assert!((!is_nonpositive(1.))); - assert!((!is_nonpositive(0.))); - assert!((is_nonpositive(-1.))); - assert!((is_nonpositive(neg_infinity))); - assert!((is_nonpositive(1./neg_infinity))); - assert!((!is_nonpositive(NaN))); -} - -#[test] -pub fn test_nonnegative() { - assert!((is_nonnegative(infinity))); - assert!((is_nonnegative(1.))); - assert!((is_nonnegative(0.))); - assert!((!is_nonnegative(-1.))); - assert!((!is_nonnegative(neg_infinity))); - assert!((!is_nonnegative(1./neg_infinity))); - assert!((!is_nonnegative(NaN))); -} - -#[test] -pub fn test_to_str_inf() { - assert!(to_str_digits(infinity, 10u) == ~"inf"); - assert!(to_str_digits(-infinity, 10u) == ~"-inf"); -} - -#[test] -pub fn test_round() { - assert!(round(5.8) == 6.0); - assert!(round(5.2) == 5.0); - assert!(round(3.0) == 3.0); - assert!(round(2.5) == 3.0); - assert!(round(-3.5) == -4.0); -} - - // // Local Variables: // mode: rust diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 6fbe44737d18..b495f9e7088f 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -277,181 +277,188 @@ fn to_str_radix(&self, radix: uint) -> ~str { } } -#[test] -fn test_from_str() { - assert!(from_str(~"0") == Some(0 as T)); - assert!(from_str(~"3") == Some(3 as T)); - assert!(from_str(~"10") == Some(10 as T)); - assert!(i32::from_str(~"123456789") == Some(123456789 as i32)); - assert!(from_str(~"00100") == Some(100 as T)); +#[cfg(test)] +mod tests { + use super::*; + use super::inst::T; + use prelude::*; - assert!(from_str(~"-1") == Some(-1 as T)); - assert!(from_str(~"-3") == Some(-3 as T)); - assert!(from_str(~"-10") == Some(-10 as T)); - assert!(i32::from_str(~"-123456789") == Some(-123456789 as i32)); - assert!(from_str(~"-00100") == Some(-100 as T)); + #[test] + fn test_from_str() { + assert!(from_str(~"0") == Some(0 as T)); + assert!(from_str(~"3") == Some(3 as T)); + assert!(from_str(~"10") == Some(10 as T)); + assert!(i32::from_str(~"123456789") == Some(123456789 as i32)); + assert!(from_str(~"00100") == Some(100 as T)); - assert!(from_str(~" ").is_none()); - assert!(from_str(~"x").is_none()); -} + assert!(from_str(~"-1") == Some(-1 as T)); + assert!(from_str(~"-3") == Some(-3 as T)); + assert!(from_str(~"-10") == Some(-10 as T)); + assert!(i32::from_str(~"-123456789") == Some(-123456789 as i32)); + assert!(from_str(~"-00100") == Some(-100 as T)); -#[test] -fn test_parse_bytes() { - use str::to_bytes; - assert!(parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T)); - assert!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T)); - assert!(parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T)); - assert!(i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32)); - assert!(i32::parse_bytes(to_bytes(~"ffff"), 16u) == - Some(65535 as i32)); - assert!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) == - Some(65535 as i32)); - assert!(parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T)); - assert!(parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T)); - - assert!(parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T)); - assert!(parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T)); - assert!(parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T)); - assert!(i32::parse_bytes(to_bytes(~"-123"), 16u) == - Some(-291 as i32)); - assert!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) == - Some(-65535 as i32)); - assert!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == - Some(-65535 as i32)); - assert!(parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T)); - assert!(parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T)); - - assert!(parse_bytes(to_bytes(~"Z"), 35u).is_none()); - assert!(parse_bytes(to_bytes(~"-9"), 2u).is_none()); -} - -#[test] -fn test_to_str() { - assert!((to_str_radix(0 as T, 10u) == ~"0")); - assert!((to_str_radix(1 as T, 10u) == ~"1")); - assert!((to_str_radix(-1 as T, 10u) == ~"-1")); - assert!((to_str_radix(127 as T, 16u) == ~"7f")); - assert!((to_str_radix(100 as T, 10u) == ~"100")); - -} - -#[test] -fn test_int_to_str_overflow() { - let mut i8_val: i8 = 127_i8; - assert!((i8::to_str(i8_val) == ~"127")); - - i8_val += 1 as i8; - assert!((i8::to_str(i8_val) == ~"-128")); - - let mut i16_val: i16 = 32_767_i16; - assert!((i16::to_str(i16_val) == ~"32767")); - - i16_val += 1 as i16; - assert!((i16::to_str(i16_val) == ~"-32768")); - - let mut i32_val: i32 = 2_147_483_647_i32; - assert!((i32::to_str(i32_val) == ~"2147483647")); - - i32_val += 1 as i32; - assert!((i32::to_str(i32_val) == ~"-2147483648")); - - let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert!((i64::to_str(i64_val) == ~"9223372036854775807")); - - i64_val += 1 as i64; - assert!((i64::to_str(i64_val) == ~"-9223372036854775808")); -} - -#[test] -fn test_int_from_str_overflow() { - let mut i8_val: i8 = 127_i8; - assert!((i8::from_str(~"127") == Some(i8_val))); - assert!((i8::from_str(~"128").is_none())); - - i8_val += 1 as i8; - assert!((i8::from_str(~"-128") == Some(i8_val))); - assert!((i8::from_str(~"-129").is_none())); - - let mut i16_val: i16 = 32_767_i16; - assert!((i16::from_str(~"32767") == Some(i16_val))); - assert!((i16::from_str(~"32768").is_none())); - - i16_val += 1 as i16; - assert!((i16::from_str(~"-32768") == Some(i16_val))); - assert!((i16::from_str(~"-32769").is_none())); - - let mut i32_val: i32 = 2_147_483_647_i32; - assert!((i32::from_str(~"2147483647") == Some(i32_val))); - assert!((i32::from_str(~"2147483648").is_none())); - - i32_val += 1 as i32; - assert!((i32::from_str(~"-2147483648") == Some(i32_val))); - assert!((i32::from_str(~"-2147483649").is_none())); - - let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert!((i64::from_str(~"9223372036854775807") == Some(i64_val))); - assert!((i64::from_str(~"9223372036854775808").is_none())); - - i64_val += 1 as i64; - assert!((i64::from_str(~"-9223372036854775808") == Some(i64_val))); - assert!((i64::from_str(~"-9223372036854775809").is_none())); -} - -#[test] -pub fn test_ranges() { - let mut l = ~[]; - - for range(0,3) |i| { - l.push(i); + assert!(from_str(~" ").is_none()); + assert!(from_str(~"x").is_none()); } - for range_rev(13,10) |i| { - l.push(i); - } - for range_step(20,26,2) |i| { - l.push(i); - } - for range_step(36,30,-2) |i| { - l.push(i); - } - for range_step(max_value - 2, max_value, 2) |i| { - l.push(i); - } - for range_step(max_value - 3, max_value, 2) |i| { - l.push(i); - } - for range_step(min_value + 2, min_value, -2) |i| { - l.push(i); - } - for range_step(min_value + 3, min_value, -2) |i| { - l.push(i); - } - assert_eq!(l, ~[0,1,2, - 13,12,11, - 20,22,24, - 36,34,32, - max_value-2, - max_value-3,max_value-1, - min_value+2, - min_value+3,min_value+1]); - // None of the `fail`s should execute. - for range(10,0) |_i| { - fail!(~"unreachable"); - } - for range_rev(0,10) |_i| { - fail!(~"unreachable"); - } - for range_step(10,0,1) |_i| { - fail!(~"unreachable"); - } - for range_step(0,10,-1) |_i| { - fail!(~"unreachable"); - } -} + #[test] + fn test_parse_bytes() { + use str::to_bytes; + assert!(parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T)); + assert!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T)); + assert!(parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T)); + assert!(i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32)); + assert!(i32::parse_bytes(to_bytes(~"ffff"), 16u) == + Some(65535 as i32)); + assert!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) == + Some(65535 as i32)); + assert!(parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T)); + assert!(parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T)); -#[test] -#[should_fail] -#[ignore(cfg(windows))] -fn test_range_step_zero_step() { - for range_step(0,10,0) |_i| {} -} + assert!(parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T)); + assert!(parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T)); + assert!(parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T)); + assert!(i32::parse_bytes(to_bytes(~"-123"), 16u) == + Some(-291 as i32)); + assert!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) == + Some(-65535 as i32)); + assert!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == + Some(-65535 as i32)); + assert!(parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T)); + assert!(parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T)); + + assert!(parse_bytes(to_bytes(~"Z"), 35u).is_none()); + assert!(parse_bytes(to_bytes(~"-9"), 2u).is_none()); + } + + #[test] + fn test_to_str() { + assert!((to_str_radix(0 as T, 10u) == ~"0")); + assert!((to_str_radix(1 as T, 10u) == ~"1")); + assert!((to_str_radix(-1 as T, 10u) == ~"-1")); + assert!((to_str_radix(127 as T, 16u) == ~"7f")); + assert!((to_str_radix(100 as T, 10u) == ~"100")); + + } + + #[test] + fn test_int_to_str_overflow() { + let mut i8_val: i8 = 127_i8; + assert!((i8::to_str(i8_val) == ~"127")); + + i8_val += 1 as i8; + assert!((i8::to_str(i8_val) == ~"-128")); + + let mut i16_val: i16 = 32_767_i16; + assert!((i16::to_str(i16_val) == ~"32767")); + + i16_val += 1 as i16; + assert!((i16::to_str(i16_val) == ~"-32768")); + + let mut i32_val: i32 = 2_147_483_647_i32; + assert!((i32::to_str(i32_val) == ~"2147483647")); + + i32_val += 1 as i32; + assert!((i32::to_str(i32_val) == ~"-2147483648")); + + let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; + assert!((i64::to_str(i64_val) == ~"9223372036854775807")); + + i64_val += 1 as i64; + assert!((i64::to_str(i64_val) == ~"-9223372036854775808")); + } + + #[test] + fn test_int_from_str_overflow() { + let mut i8_val: i8 = 127_i8; + assert!((i8::from_str(~"127") == Some(i8_val))); + assert!((i8::from_str(~"128").is_none())); + + i8_val += 1 as i8; + assert!((i8::from_str(~"-128") == Some(i8_val))); + assert!((i8::from_str(~"-129").is_none())); + + let mut i16_val: i16 = 32_767_i16; + assert!((i16::from_str(~"32767") == Some(i16_val))); + assert!((i16::from_str(~"32768").is_none())); + + i16_val += 1 as i16; + assert!((i16::from_str(~"-32768") == Some(i16_val))); + assert!((i16::from_str(~"-32769").is_none())); + + let mut i32_val: i32 = 2_147_483_647_i32; + assert!((i32::from_str(~"2147483647") == Some(i32_val))); + assert!((i32::from_str(~"2147483648").is_none())); + + i32_val += 1 as i32; + assert!((i32::from_str(~"-2147483648") == Some(i32_val))); + assert!((i32::from_str(~"-2147483649").is_none())); + + let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; + assert!((i64::from_str(~"9223372036854775807") == Some(i64_val))); + assert!((i64::from_str(~"9223372036854775808").is_none())); + + i64_val += 1 as i64; + assert!((i64::from_str(~"-9223372036854775808") == Some(i64_val))); + assert!((i64::from_str(~"-9223372036854775809").is_none())); + } + + #[test] + fn test_ranges() { + let mut l = ~[]; + + for range(0,3) |i| { + l.push(i); + } + for range_rev(13,10) |i| { + l.push(i); + } + for range_step(20,26,2) |i| { + l.push(i); + } + for range_step(36,30,-2) |i| { + l.push(i); + } + for range_step(max_value - 2, max_value, 2) |i| { + l.push(i); + } + for range_step(max_value - 3, max_value, 2) |i| { + l.push(i); + } + for range_step(min_value + 2, min_value, -2) |i| { + l.push(i); + } + for range_step(min_value + 3, min_value, -2) |i| { + l.push(i); + } + assert_eq!(l, ~[0,1,2, + 13,12,11, + 20,22,24, + 36,34,32, + max_value-2, + max_value-3,max_value-1, + min_value+2, + min_value+3,min_value+1]); + + // None of the `fail`s should execute. + for range(10,0) |_i| { + fail!(~"unreachable"); + } + for range_rev(0,10) |_i| { + fail!(~"unreachable"); + } + for range_step(10,0,1) |_i| { + fail!(~"unreachable"); + } + for range_step(0,10,-1) |_i| { + fail!(~"unreachable"); + } + } + + #[test] + #[should_fail] + #[ignore(cfg(windows))] + fn test_range_step_zero_step() { + for range_step(0,10,0) |_i| {} + } +} \ No newline at end of file diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 1cbdabafdab9..af6557e9881f 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -242,184 +242,190 @@ fn to_str_radix(&self, radix: uint) -> ~str { } } -#[test] -pub fn test_to_str() { - assert!(to_str_radix(0 as T, 10u) == ~"0"); - assert!(to_str_radix(1 as T, 10u) == ~"1"); - assert!(to_str_radix(2 as T, 10u) == ~"2"); - assert!(to_str_radix(11 as T, 10u) == ~"11"); - assert!(to_str_radix(11 as T, 16u) == ~"b"); - assert!(to_str_radix(255 as T, 16u) == ~"ff"); - assert!(to_str_radix(0xff as T, 10u) == ~"255"); -} - -#[test] -pub fn test_from_str() { - assert!(from_str(~"0") == Some(0u as T)); - assert!(from_str(~"3") == Some(3u as T)); - assert!(from_str(~"10") == Some(10u as T)); - assert!(u32::from_str(~"123456789") == Some(123456789 as u32)); - assert!(from_str(~"00100") == Some(100u as T)); - - assert!(from_str(~"").is_none()); - assert!(from_str(~" ").is_none()); - assert!(from_str(~"x").is_none()); -} - -#[test] -pub fn test_parse_bytes() { - use str::to_bytes; - assert!(parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T)); - assert!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T)); - assert!(parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T)); - assert!(u16::parse_bytes(to_bytes(~"123"), 16u) == - Some(291u as u16)); - assert!(u16::parse_bytes(to_bytes(~"ffff"), 16u) == - Some(65535u as u16)); - assert!(parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T)); - - assert!(parse_bytes(to_bytes(~"Z"), 10u).is_none()); - assert!(parse_bytes(to_bytes(~"_"), 2u).is_none()); -} - -#[test] -fn test_uint_to_str_overflow() { - let mut u8_val: u8 = 255_u8; - assert!((u8::to_str(u8_val) == ~"255")); - - u8_val += 1 as u8; - assert!((u8::to_str(u8_val) == ~"0")); - - let mut u16_val: u16 = 65_535_u16; - assert!((u16::to_str(u16_val) == ~"65535")); - - u16_val += 1 as u16; - assert!((u16::to_str(u16_val) == ~"0")); - - let mut u32_val: u32 = 4_294_967_295_u32; - assert!((u32::to_str(u32_val) == ~"4294967295")); - - u32_val += 1 as u32; - assert!((u32::to_str(u32_val) == ~"0")); - - let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert!((u64::to_str(u64_val) == ~"18446744073709551615")); - - u64_val += 1 as u64; - assert!((u64::to_str(u64_val) == ~"0")); -} - -#[test] -fn test_uint_from_str_overflow() { - let mut u8_val: u8 = 255_u8; - assert!((u8::from_str(~"255") == Some(u8_val))); - assert!((u8::from_str(~"256").is_none())); - - u8_val += 1 as u8; - assert!((u8::from_str(~"0") == Some(u8_val))); - assert!((u8::from_str(~"-1").is_none())); - - let mut u16_val: u16 = 65_535_u16; - assert!((u16::from_str(~"65535") == Some(u16_val))); - assert!((u16::from_str(~"65536").is_none())); - - u16_val += 1 as u16; - assert!((u16::from_str(~"0") == Some(u16_val))); - assert!((u16::from_str(~"-1").is_none())); - - let mut u32_val: u32 = 4_294_967_295_u32; - assert!((u32::from_str(~"4294967295") == Some(u32_val))); - assert!((u32::from_str(~"4294967296").is_none())); - - u32_val += 1 as u32; - assert!((u32::from_str(~"0") == Some(u32_val))); - assert!((u32::from_str(~"-1").is_none())); - - let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert!((u64::from_str(~"18446744073709551615") == Some(u64_val))); - assert!((u64::from_str(~"18446744073709551616").is_none())); - - u64_val += 1 as u64; - assert!((u64::from_str(~"0") == Some(u64_val))); - assert!((u64::from_str(~"-1").is_none())); -} - -#[test] -#[should_fail] -#[ignore(cfg(windows))] -pub fn to_str_radix1() { - uint::to_str_radix(100u, 1u); -} - -#[test] -#[should_fail] -#[ignore(cfg(windows))] -pub fn to_str_radix37() { - uint::to_str_radix(100u, 37u); -} - -#[test] -pub fn test_ranges() { - let mut l = ~[]; - - for range(0,3) |i| { - l.push(i); - } - for range_rev(13,10) |i| { - l.push(i); - } - for range_step(20,26,2) |i| { - l.push(i); - } - for range_step(36,30,-2) |i| { - l.push(i); - } - for range_step(max_value - 2, max_value, 2) |i| { - l.push(i); - } - for range_step(max_value - 3, max_value, 2) |i| { - l.push(i); - } - for range_step(min_value + 2, min_value, -2) |i| { - l.push(i); - } - for range_step(min_value + 3, min_value, -2) |i| { - l.push(i); +#[cfg(test)] +mod tests { + use super::*; + use super::inst::T; + use prelude::*; + #[test] + pub fn test_to_str() { + assert!(to_str_radix(0 as T, 10u) == ~"0"); + assert!(to_str_radix(1 as T, 10u) == ~"1"); + assert!(to_str_radix(2 as T, 10u) == ~"2"); + assert!(to_str_radix(11 as T, 10u) == ~"11"); + assert!(to_str_radix(11 as T, 16u) == ~"b"); + assert!(to_str_radix(255 as T, 16u) == ~"ff"); + assert!(to_str_radix(0xff as T, 10u) == ~"255"); } - assert_eq!(l, ~[0,1,2, - 13,12,11, - 20,22,24, - 36,34,32, - max_value-2, - max_value-3,max_value-1, - min_value+2, - min_value+3,min_value+1]); + #[test] + pub fn test_from_str() { + assert!(from_str(~"0") == Some(0u as T)); + assert!(from_str(~"3") == Some(3u as T)); + assert!(from_str(~"10") == Some(10u as T)); + assert!(u32::from_str(~"123456789") == Some(123456789 as u32)); + assert!(from_str(~"00100") == Some(100u as T)); - // None of the `fail`s should execute. - for range(0,0) |_i| { - fail!(~"unreachable"); + assert!(from_str(~"").is_none()); + assert!(from_str(~" ").is_none()); + assert!(from_str(~"x").is_none()); } - for range_rev(0,0) |_i| { - fail!(~"unreachable"); - } - for range_step(10,0,1) |_i| { - fail!(~"unreachable"); - } - for range_step(0,1,-10) |_i| { - fail!(~"unreachable"); - } -} -#[test] -#[should_fail] -#[ignore(cfg(windows))] -fn test_range_step_zero_step_up() { - for range_step(0,10,0) |_i| {} -} -#[test] -#[should_fail] -#[ignore(cfg(windows))] -fn test_range_step_zero_step_down() { - for range_step(0,-10,0) |_i| {} -} + #[test] + pub fn test_parse_bytes() { + use str::to_bytes; + assert!(parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T)); + assert!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T)); + assert!(parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T)); + assert!(u16::parse_bytes(to_bytes(~"123"), 16u) == + Some(291u as u16)); + assert!(u16::parse_bytes(to_bytes(~"ffff"), 16u) == + Some(65535u as u16)); + assert!(parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T)); + + assert!(parse_bytes(to_bytes(~"Z"), 10u).is_none()); + assert!(parse_bytes(to_bytes(~"_"), 2u).is_none()); + } + + #[test] + fn test_uint_to_str_overflow() { + let mut u8_val: u8 = 255_u8; + assert!((u8::to_str(u8_val) == ~"255")); + + u8_val += 1 as u8; + assert!((u8::to_str(u8_val) == ~"0")); + + let mut u16_val: u16 = 65_535_u16; + assert!((u16::to_str(u16_val) == ~"65535")); + + u16_val += 1 as u16; + assert!((u16::to_str(u16_val) == ~"0")); + + let mut u32_val: u32 = 4_294_967_295_u32; + assert!((u32::to_str(u32_val) == ~"4294967295")); + + u32_val += 1 as u32; + assert!((u32::to_str(u32_val) == ~"0")); + + let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; + assert!((u64::to_str(u64_val) == ~"18446744073709551615")); + + u64_val += 1 as u64; + assert!((u64::to_str(u64_val) == ~"0")); + } + + #[test] + fn test_uint_from_str_overflow() { + let mut u8_val: u8 = 255_u8; + assert!((u8::from_str(~"255") == Some(u8_val))); + assert!((u8::from_str(~"256").is_none())); + + u8_val += 1 as u8; + assert!((u8::from_str(~"0") == Some(u8_val))); + assert!((u8::from_str(~"-1").is_none())); + + let mut u16_val: u16 = 65_535_u16; + assert!((u16::from_str(~"65535") == Some(u16_val))); + assert!((u16::from_str(~"65536").is_none())); + + u16_val += 1 as u16; + assert!((u16::from_str(~"0") == Some(u16_val))); + assert!((u16::from_str(~"-1").is_none())); + + let mut u32_val: u32 = 4_294_967_295_u32; + assert!((u32::from_str(~"4294967295") == Some(u32_val))); + assert!((u32::from_str(~"4294967296").is_none())); + + u32_val += 1 as u32; + assert!((u32::from_str(~"0") == Some(u32_val))); + assert!((u32::from_str(~"-1").is_none())); + + let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; + assert!((u64::from_str(~"18446744073709551615") == Some(u64_val))); + assert!((u64::from_str(~"18446744073709551616").is_none())); + + u64_val += 1 as u64; + assert!((u64::from_str(~"0") == Some(u64_val))); + assert!((u64::from_str(~"-1").is_none())); + } + + #[test] + #[should_fail] + #[ignore(cfg(windows))] + pub fn to_str_radix1() { + uint::to_str_radix(100u, 1u); + } + + #[test] + #[should_fail] + #[ignore(cfg(windows))] + pub fn to_str_radix37() { + uint::to_str_radix(100u, 37u); + } + + #[test] + pub fn test_ranges() { + let mut l = ~[]; + + for range(0,3) |i| { + l.push(i); + } + for range_rev(13,10) |i| { + l.push(i); + } + for range_step(20,26,2) |i| { + l.push(i); + } + for range_step(36,30,-2) |i| { + l.push(i); + } + for range_step(max_value - 2, max_value, 2) |i| { + l.push(i); + } + for range_step(max_value - 3, max_value, 2) |i| { + l.push(i); + } + for range_step(min_value + 2, min_value, -2) |i| { + l.push(i); + } + for range_step(min_value + 3, min_value, -2) |i| { + l.push(i); + } + + assert_eq!(l, ~[0,1,2, + 13,12,11, + 20,22,24, + 36,34,32, + max_value-2, + max_value-3,max_value-1, + min_value+2, + min_value+3,min_value+1]); + + // None of the `fail`s should execute. + for range(0,0) |_i| { + fail!(~"unreachable"); + } + for range_rev(0,0) |_i| { + fail!(~"unreachable"); + } + for range_step(10,0,1) |_i| { + fail!(~"unreachable"); + } + for range_step(0,1,-10) |_i| { + fail!(~"unreachable"); + } + } + + #[test] + #[should_fail] + #[ignore(cfg(windows))] + fn test_range_step_zero_step_up() { + for range_step(0,10,0) |_i| {} + } + #[test] + #[should_fail] + #[ignore(cfg(windows))] + fn test_range_step_zero_step_down() { + for range_step(0,-10,0) |_i| {} + } +} \ No newline at end of file diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 18f8030d5b84..fddb2af55870 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -957,13 +957,13 @@ pub fn make_none() -> Option { None } } #[cfg(test)] -pub mod test { +mod test { use either::Right; use comm::{Chan, Port, oneshot, recv_one, stream, Select2, GenericChan, Peekable}; #[test] - pub fn test_select2() { + fn test_select2() { let (p1, c1) = stream(); let (p2, c2) = stream(); @@ -978,7 +978,7 @@ pub fn test_select2() { } #[test] - pub fn test_oneshot() { + fn test_oneshot() { let (c, p) = oneshot::init(); oneshot::client::send(c, ()); diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 14e17de4fbda..ebde37e77b42 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -15,8 +15,6 @@ use libc::{c_void, size_t}; use sys; -#[cfg(test)] use vec; -#[cfg(test)] use str; #[cfg(notest)] use cmp::{Eq, Ord}; use uint; @@ -341,101 +339,101 @@ fn gt(&self, other: & &'self const T) -> bool { } } -#[test] -pub fn test() { - unsafe { - struct Pair {mut fst: int, mut snd: int}; - let mut p = Pair {fst: 10, snd: 20}; - let pptr: *mut Pair = &mut p; - let iptr: *mut int = cast::reinterpret_cast(&pptr); - assert!((*iptr == 10));; - *iptr = 30; - assert!((*iptr == 30)); - assert!((p.fst == 30));; +#[cfg(test)] +pub mod ptr_tests { + use super::*; + use prelude::*; - *pptr = Pair {fst: 50, snd: 60}; - assert!((*iptr == 50)); - assert!((p.fst == 50)); - assert!((p.snd == 60)); + #[test] + fn test() { + unsafe { + struct Pair {mut fst: int, mut snd: int}; + let mut p = Pair {fst: 10, snd: 20}; + let pptr: *mut Pair = &mut p; + let iptr: *mut int = cast::reinterpret_cast(&pptr); + assert!((*iptr == 10));; + *iptr = 30; + assert!((*iptr == 30)); + assert!((p.fst == 30));; - let mut v0 = ~[32000u16, 32001u16, 32002u16]; - let mut v1 = ~[0u16, 0u16, 0u16]; + *pptr = Pair {fst: 50, snd: 60}; + assert!((*iptr == 50)); + assert!((p.fst == 50)); + assert!((p.snd == 60)); - copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 1u), - offset(vec::raw::to_ptr(v0), 1u), 1u); - assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16)); - copy_memory(vec::raw::to_mut_ptr(v1), - offset(vec::raw::to_ptr(v0), 2u), 1u); - assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && - v1[2] == 0u16)); - copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u), - vec::raw::to_ptr(v0), 1u); - assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && - v1[2] == 32000u16)); + let mut v0 = ~[32000u16, 32001u16, 32002u16]; + let mut v1 = ~[0u16, 0u16, 0u16]; + + copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 1u), + offset(vec::raw::to_ptr(v0), 1u), 1u); + assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16)); + copy_memory(vec::raw::to_mut_ptr(v1), + offset(vec::raw::to_ptr(v0), 2u), 1u); + assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && + v1[2] == 0u16)); + copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u), + vec::raw::to_ptr(v0), 1u); + assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && + v1[2] == 32000u16)); + } } -} -#[test] -pub fn test_position() { - use str::as_c_str; - use libc::c_char; + #[test] + fn test_position() { + use str::as_c_str; + use libc::c_char; - let s = ~"hello"; - unsafe { - assert!(2u == as_c_str(s, |p| position(p, - |c| *c == 'l' as c_char))); - assert!(4u == as_c_str(s, |p| position(p, - |c| *c == 'o' as c_char))); - assert!(5u == as_c_str(s, |p| position(p, - |c| *c == 0 as c_char))); + let s = ~"hello"; + unsafe { + assert!(2u == as_c_str(s, |p| position(p, + |c| *c == 'l' as c_char))); + assert!(4u == as_c_str(s, |p| position(p, + |c| *c == 'o' as c_char))); + assert!(5u == as_c_str(s, |p| position(p, + |c| *c == 0 as c_char))); + } } -} -#[test] -pub fn test_buf_len() { - let s0 = ~"hello"; - let s1 = ~"there"; - let s2 = ~"thing"; - do str::as_c_str(s0) |p0| { - do str::as_c_str(s1) |p1| { - do str::as_c_str(s2) |p2| { - let v = ~[p0, p1, p2, null()]; - do vec::as_imm_buf(v) |vp, len| { - assert!(unsafe { buf_len(vp) } == 3u); - assert!(len == 4u); + #[test] + fn test_buf_len() { + let s0 = ~"hello"; + let s1 = ~"there"; + let s2 = ~"thing"; + do str::as_c_str(s0) |p0| { + do str::as_c_str(s1) |p1| { + do str::as_c_str(s2) |p2| { + let v = ~[p0, p1, p2, null()]; + do vec::as_imm_buf(v) |vp, len| { + assert!(unsafe { buf_len(vp) } == 3u); + assert!(len == 4u); + } } } } } -} -#[test] -pub fn test_is_null() { - let p: *int = null(); - assert!(p.is_null()); - assert!(!p.is_not_null()); - - let q = offset(p, 1u); - assert!(!q.is_null()); - assert!(q.is_not_null()); - - let mp: *mut int = mut_null(); - assert!(mp.is_null()); - assert!(!mp.is_not_null()); - - let mq = mp.offset(1u); - assert!(!mq.is_null()); - assert!(mq.is_not_null()); -} - -#[cfg(test)] -pub mod ptr_tests { - use ptr; - use str; - use libc; - use vec; #[test] - pub fn test_ptr_array_each_with_len() { + fn test_is_null() { + let p: *int = null(); + assert!(p.is_null()); + assert!(!p.is_not_null()); + + let q = offset(p, 1u); + assert!(!q.is_null()); + assert!(q.is_not_null()); + + let mp: *mut int = mut_null(); + assert!(mp.is_null()); + assert!(!mp.is_not_null()); + + let mq = mp.offset(1u); + assert!(!mq.is_null()); + assert!(mq.is_not_null()); + } + + + #[test] + fn test_ptr_array_each_with_len() { unsafe { let one = ~"oneOne"; let two = ~"twoTwo"; @@ -451,22 +449,22 @@ pub fn test_ptr_array_each_with_len() { let arr_ptr = &arr[0]; let mut ctr = 0; let mut iteration_count = 0; - ptr::array_each_with_len(arr_ptr, vec::len(arr), - |e| { - let actual = str::raw::from_c_str(e); - let expected = copy expected_arr[ctr]; - debug!( - "test_ptr_array_each e: %s, a: %s", - expected, actual); - assert!(actual == expected); - ctr += 1; - iteration_count += 1; - }); + array_each_with_len(arr_ptr, vec::len(arr), + |e| { + let actual = str::raw::from_c_str(e); + let expected = copy expected_arr[ctr]; + debug!( + "test_ptr_array_each e: %s, a: %s", + expected, actual); + assert!(actual == expected); + ctr += 1; + iteration_count += 1; + }); assert!(iteration_count == 3u); } } #[test] - pub fn test_ptr_array_each() { + fn test_ptr_array_each() { unsafe { let one = ~"oneOne"; let two = ~"twoTwo"; @@ -484,12 +482,12 @@ pub fn test_ptr_array_each() { let arr_ptr = &arr[0]; let mut ctr = 0; let mut iteration_count = 0; - ptr::array_each(arr_ptr, |e| { + array_each(arr_ptr, |e| { let actual = str::raw::from_c_str(e); let expected = copy expected_arr[ctr]; debug!( "test_ptr_array_each e: %s, a: %s", - expected, actual); + expected, actual); assert!(actual == expected); ctr += 1; iteration_count += 1; @@ -500,9 +498,9 @@ pub fn test_ptr_array_each() { #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_ptr_array_each_with_len_null_ptr() { + fn test_ptr_array_each_with_len_null_ptr() { unsafe { - ptr::array_each_with_len(0 as **libc::c_char, 1, |e| { + array_each_with_len(0 as **libc::c_char, 1, |e| { str::raw::from_c_str(e); }); } @@ -510,9 +508,9 @@ pub fn test_ptr_array_each_with_len_null_ptr() { #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_ptr_array_each_null_ptr() { + fn test_ptr_array_each_null_ptr() { unsafe { - ptr::array_each(0 as **libc::c_char, |e| { + array_each(0 as **libc::c_char, |e| { str::raw::from_c_str(e); }); } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index c6400ccded8a..0a93a651a857 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -747,12 +747,12 @@ pub fn random() -> uint { #[cfg(test)] -pub mod tests { +mod tests { use option::{Option, Some}; use rand; #[test] - pub fn rng_seeded() { + fn rng_seeded() { let seed = rand::seed(); let ra = rand::seeded_rng(seed); let rb = rand::seeded_rng(seed); @@ -760,7 +760,7 @@ pub fn rng_seeded() { } #[test] - pub fn rng_seeded_custom_seed() { + fn rng_seeded_custom_seed() { // much shorter than generated seeds which are 1024 bytes let seed = [2u8, 32u8, 4u8, 32u8, 51u8]; let ra = rand::seeded_rng(seed); @@ -769,7 +769,7 @@ pub fn rng_seeded_custom_seed() { } #[test] - pub fn rng_seeded_custom_seed2() { + fn rng_seeded_custom_seed2() { let seed = [2u8, 32u8, 4u8, 32u8, 51u8]; let ra = rand::seeded_rng(seed); // Regression test that isaac is actually using the above vector @@ -780,7 +780,7 @@ pub fn rng_seeded_custom_seed2() { } #[test] - pub fn gen_int_range() { + fn gen_int_range() { let r = rand::Rng(); let a = r.gen_int_range(-3, 42); assert!(a >= -3 && a < 42); @@ -791,12 +791,12 @@ pub fn gen_int_range() { #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn gen_int_from_fail() { + fn gen_int_from_fail() { rand::Rng().gen_int_range(5, -2); } #[test] - pub fn gen_uint_range() { + fn gen_uint_range() { let r = rand::Rng(); let a = r.gen_uint_range(3u, 42u); assert!(a >= 3u && a < 42u); @@ -807,12 +807,12 @@ pub fn gen_uint_range() { #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn gen_uint_range_fail() { + fn gen_uint_range_fail() { rand::Rng().gen_uint_range(5u, 2u); } #[test] - pub fn gen_float() { + fn gen_float() { let r = rand::Rng(); let a = r.gen_float(); let b = r.gen_float(); @@ -820,14 +820,14 @@ pub fn gen_float() { } #[test] - pub fn gen_weighted_bool() { + fn gen_weighted_bool() { let r = rand::Rng(); assert!(r.gen_weighted_bool(0u) == true); assert!(r.gen_weighted_bool(1u) == true); } #[test] - pub fn gen_str() { + fn gen_str() { let r = rand::Rng(); debug!(r.gen_str(10u)); debug!(r.gen_str(10u)); @@ -838,7 +838,7 @@ pub fn gen_str() { } #[test] - pub fn gen_bytes() { + fn gen_bytes() { let r = rand::Rng(); assert!(r.gen_bytes(0u).len() == 0u); assert!(r.gen_bytes(10u).len() == 10u); @@ -846,13 +846,13 @@ pub fn gen_bytes() { } #[test] - pub fn choose() { + fn choose() { let r = rand::Rng(); assert!(r.choose([1, 1, 1]) == 1); } #[test] - pub fn choose_option() { + fn choose_option() { let r = rand::Rng(); let x: Option = r.choose_option([]); assert!(x.is_none()); @@ -860,7 +860,7 @@ pub fn choose_option() { } #[test] - pub fn choose_weighted() { + fn choose_weighted() { let r = rand::Rng(); assert!(r.choose_weighted(~[ rand::Weighted { weight: 1u, item: 42 }, @@ -872,7 +872,7 @@ pub fn choose_weighted() { } #[test] - pub fn choose_weighted_option() { + fn choose_weighted_option() { let r = rand::Rng(); assert!(r.choose_weighted_option(~[ rand::Weighted { weight: 1u, item: 42 }, @@ -886,7 +886,7 @@ pub fn choose_weighted_option() { } #[test] - pub fn weighted_vec() { + fn weighted_vec() { let r = rand::Rng(); let empty: ~[int] = ~[]; assert!(r.weighted_vec(~[]) == empty); @@ -898,7 +898,7 @@ pub fn weighted_vec() { } #[test] - pub fn shuffle() { + fn shuffle() { let r = rand::Rng(); let empty: ~[int] = ~[]; assert!(r.shuffle(~[]) == empty); @@ -906,7 +906,7 @@ pub fn shuffle() { } #[test] - pub fn task_rng() { + fn task_rng() { let r = rand::task_rng(); r.gen_int(); assert!(r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]); @@ -914,7 +914,7 @@ pub fn task_rng() { } #[test] - pub fn random() { + fn random() { // not sure how to test this aside from just getting a number let _n : uint = rand::random(); } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 49df2938afd4..8e247a25012f 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -521,7 +521,7 @@ mod tests { // Regression test for memory leaks #[ignore(cfg(windows))] // FIXME (#2626) - pub fn test_leaks() { + fn test_leaks() { run::run_program("echo", []); run::start_program("echo", []); run::program_output("echo", []); @@ -529,7 +529,7 @@ pub fn test_leaks() { #[test] #[allow(non_implicitly_copyable_typarams)] - pub fn test_pipes() { + fn test_pipes() { let pipe_in = os::pipe(); let pipe_out = os::pipe(); let pipe_err = os::pipe(); @@ -555,7 +555,7 @@ pub fn test_pipes() { } #[test] - pub fn waitpid() { + fn waitpid() { let pid = run::spawn_process("false", [], &None, &None, 0i32, 0i32, 0i32); @@ -564,20 +564,20 @@ pub fn waitpid() { } #[test] - pub fn test_destroy_once() { + fn test_destroy_once() { let mut p = run::start_program("echo", []); p.destroy(); // this shouldn't crash (and nor should the destructor) } #[test] - pub fn test_destroy_twice() { + fn test_destroy_twice() { let mut p = run::start_program("echo", []); p.destroy(); // this shouldnt crash... p.destroy(); // ...and nor should this (and nor should the destructor) } #[cfg(unix)] // there is no way to sleep on windows from inside libcore... - pub fn test_destroy_actually_kills(force: bool) { + fn test_destroy_actually_kills(force: bool) { let path = Path(fmt!("test/core-run-test-destroy-actually-kills-%?.tmp", force)); os::remove_file(&path); @@ -598,13 +598,13 @@ pub fn test_destroy_actually_kills(force: bool) { #[test] #[cfg(unix)] - pub fn test_unforced_destroy_actually_kills() { + fn test_unforced_destroy_actually_kills() { test_destroy_actually_kills(false); } #[test] #[cfg(unix)] - pub fn test_forced_destroy_actually_kills() { + fn test_forced_destroy_actually_kills() { test_destroy_actually_kills(true); } } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 678005ce06f9..04f96f5eb229 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -160,12 +160,12 @@ pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! { } #[cfg(test)] -pub mod tests { +mod tests { use cast; use sys::{Closure, pref_align_of, size_of, nonzero_size_of}; #[test] - pub fn size_of_basic() { + fn size_of_basic() { assert!(size_of::() == 1u); assert!(size_of::() == 2u); assert!(size_of::() == 4u); @@ -176,20 +176,20 @@ pub fn size_of_basic() { #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] - pub fn size_of_32() { + fn size_of_32() { assert!(size_of::() == 4u); assert!(size_of::<*uint>() == 4u); } #[test] #[cfg(target_arch = "x86_64")] - pub fn size_of_64() { + fn size_of_64() { assert!(size_of::() == 8u); assert!(size_of::<*uint>() == 8u); } #[test] - pub fn nonzero_size_of_basic() { + fn nonzero_size_of_basic() { type Z = [i8, ..0]; assert!(size_of::() == 0u); assert!(nonzero_size_of::() == 1u); @@ -197,7 +197,7 @@ pub fn nonzero_size_of_basic() { } #[test] - pub fn align_of_basic() { + fn align_of_basic() { assert!(pref_align_of::() == 1u); assert!(pref_align_of::() == 2u); assert!(pref_align_of::() == 4u); @@ -207,20 +207,20 @@ pub fn align_of_basic() { #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] - pub fn align_of_32() { + fn align_of_32() { assert!(pref_align_of::() == 4u); assert!(pref_align_of::<*uint>() == 4u); } #[test] #[cfg(target_arch = "x86_64")] - pub fn align_of_64() { + fn align_of_64() { assert!(pref_align_of::() == 8u); assert!(pref_align_of::<*uint>() == 8u); } #[test] - pub fn synthesize_closure() { + fn synthesize_closure() { unsafe { let x = 10; let f: &fn(int) -> int = |y| x + y; diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index d712bf8f98f4..a6c4b6c52686 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -925,7 +925,7 @@ fn test_spawn_sched_childs_on_default_sched() { } #[cfg(test)] -pub mod testrt { +mod testrt { use libc; #[nolink] diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs index e43d321dc4d0..c057fce0abd8 100644 --- a/src/libcore/unstable.rs +++ b/src/libcore/unstable.rs @@ -286,14 +286,14 @@ unsafe fn with_imm(&self, f: &fn(x: &T) -> U) -> U { } #[cfg(test)] -pub mod tests { +mod tests { use comm; use super::exclusive; use task; use uint; #[test] - pub fn exclusive_arc() { + fn exclusive_arc() { let mut futures = ~[]; let num_tasks = 10; @@ -324,7 +324,7 @@ pub fn exclusive_arc() { } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn exclusive_poison() { + fn exclusive_poison() { // Tests that if one task fails inside of an exclusive, subsequent // accesses will also fail. let x = exclusive(1); diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index cc1168bd79dd..49935eea0e13 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -212,14 +212,14 @@ mod test { use driver::session; #[test] - pub fn test_rpaths_to_flags() { + fn test_rpaths_to_flags() { let flags = rpaths_to_flags(~[Path("path1"), Path("path2")]); assert!(flags == ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]); } #[test] - pub fn test_prefix_rpath() { + fn test_prefix_rpath() { let res = get_install_prefix_rpath("triple"); let d = Path(env!("CFG_PREFIX")) .push_rel(&Path("lib/rustc/triple/lib")); @@ -230,13 +230,13 @@ pub fn test_prefix_rpath() { } #[test] - pub fn test_prefix_rpath_abs() { + fn test_prefix_rpath_abs() { let res = get_install_prefix_rpath("triple"); assert!(res.is_absolute); } #[test] - pub fn test_minimize1() { + fn test_minimize1() { let res = minimize_rpaths([Path("rpath1"), Path("rpath2"), Path("rpath1")]); @@ -244,7 +244,7 @@ pub fn test_minimize1() { } #[test] - pub fn test_minimize2() { + fn test_minimize2() { let res = minimize_rpaths(~[Path("1a"), Path("2"), Path("2"), Path("1a"), Path("4a"),Path("1a"), Path("2"), Path("3"), Path("4a"), @@ -253,7 +253,7 @@ pub fn test_minimize2() { } #[test] - pub fn test_relative_to1() { + fn test_relative_to1() { let p1 = Path("/usr/bin/rustc"); let p2 = Path("/usr/lib/mylib"); let res = get_relative_to(&p1, &p2); @@ -261,7 +261,7 @@ pub fn test_relative_to1() { } #[test] - pub fn test_relative_to2() { + fn test_relative_to2() { let p1 = Path("/usr/bin/rustc"); let p2 = Path("/usr/bin/../lib/mylib"); let res = get_relative_to(&p1, &p2); @@ -269,7 +269,7 @@ pub fn test_relative_to2() { } #[test] - pub fn test_relative_to3() { + fn test_relative_to3() { let p1 = Path("/usr/bin/whatever/rustc"); let p2 = Path("/usr/lib/whatever/mylib"); let res = get_relative_to(&p1, &p2); @@ -277,7 +277,7 @@ pub fn test_relative_to3() { } #[test] - pub fn test_relative_to4() { + fn test_relative_to4() { let p1 = Path("/usr/bin/whatever/../rustc"); let p2 = Path("/usr/lib/whatever/mylib"); let res = get_relative_to(&p1, &p2); @@ -285,7 +285,7 @@ pub fn test_relative_to4() { } #[test] - pub fn test_relative_to5() { + fn test_relative_to5() { let p1 = Path("/usr/bin/whatever/../rustc"); let p2 = Path("/usr/lib/whatever/../mylib"); let res = get_relative_to(&p1, &p2); @@ -293,7 +293,7 @@ pub fn test_relative_to5() { } #[test] - pub fn test_relative_to6() { + fn test_relative_to6() { let p1 = Path("/1"); let p2 = Path("/2/3"); let res = get_relative_to(&p1, &p2); @@ -301,7 +301,7 @@ pub fn test_relative_to6() { } #[test] - pub fn test_relative_to7() { + fn test_relative_to7() { let p1 = Path("/1/2"); let p2 = Path("/3"); let res = get_relative_to(&p1, &p2); @@ -309,7 +309,7 @@ pub fn test_relative_to7() { } #[test] - pub fn test_relative_to8() { + fn test_relative_to8() { let p1 = Path("/home/brian/Dev/rust/build/").push_rel( &Path("stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so")); let p2 = Path("/home/brian/Dev/rust/build/stage2/bin/..").push_rel( @@ -324,7 +324,7 @@ pub fn test_relative_to8() { #[test] #[cfg(target_os = "linux")] #[cfg(target_os = "andorid")] - pub fn test_rpath_relative() { + fn test_rpath_relative() { let o = session::os_linux; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); @@ -333,7 +333,7 @@ pub fn test_rpath_relative() { #[test] #[cfg(target_os = "freebsd")] - pub fn test_rpath_relative() { + fn test_rpath_relative() { let o = session::os_freebsd; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); @@ -342,7 +342,7 @@ pub fn test_rpath_relative() { #[test] #[cfg(target_os = "macos")] - pub fn test_rpath_relative() { + fn test_rpath_relative() { // this is why refinements would be nice let o = session::os_macos; let res = get_rpath_relative_to_output(o, @@ -352,7 +352,7 @@ pub fn test_rpath_relative() { } #[test] - pub fn test_get_absolute_rpath() { + fn test_get_absolute_rpath() { let res = get_absolute_rpath(&Path("lib/libstd.so")); debug!("test_get_absolute_rpath: %s vs. %s", res.to_str(), diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index d725b7000375..a804469ac651 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -876,7 +876,7 @@ pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) { } #[cfg(test)] -pub mod test { +mod test { use core::prelude::*; use driver::driver::{build_configuration, build_session}; @@ -890,7 +890,7 @@ pub mod test { // When the user supplies --test we should implicitly supply --cfg test #[test] - pub fn test_switch_implies_cfg_test() { + fn test_switch_implies_cfg_test() { let matches = &match getopts(~[~"--test"], optgroups()) { Ok(copy m) => m, @@ -907,7 +907,7 @@ pub fn test_switch_implies_cfg_test() { // When the user supplies --test and --cfg test, don't implicitly add // another --cfg test #[test] - pub fn test_switch_implies_cfg_test_unless_cfg_test() { + fn test_switch_implies_cfg_test_unless_cfg_test() { let matches = &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { Ok(copy m) => m, diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 226905bbab72..aee5e01e0910 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -354,14 +354,14 @@ pub fn sess_os_to_meta_os(os: os) -> metadata::loader::os { } #[cfg(test)] -pub mod test { +mod test { use driver::session::{bin_crate, building_library, lib_crate}; use driver::session::{unknown_crate}; use syntax::ast; use syntax::codemap; - pub fn make_crate_type_attr(+t: ~str) -> ast::attribute { + fn make_crate_type_attr(+t: ~str) -> ast::attribute { codemap::respan(codemap::dummy_sp(), ast::attribute_ { style: ast::attr_outer, value: @codemap::respan(codemap::dummy_sp(), @@ -373,7 +373,7 @@ pub fn make_crate_type_attr(+t: ~str) -> ast::attribute { }) } - pub fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { + fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { let mut attrs = ~[]; if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; } if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; } @@ -385,43 +385,43 @@ pub fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { } #[test] - pub fn bin_crate_type_attr_results_in_bin_output() { + fn bin_crate_type_attr_results_in_bin_output() { let crate = make_crate(true, false); assert!(!building_library(unknown_crate, crate, false)); } #[test] - pub fn lib_crate_type_attr_results_in_lib_output() { + fn lib_crate_type_attr_results_in_lib_output() { let crate = make_crate(false, true); assert!(building_library(unknown_crate, crate, false)); } #[test] - pub fn bin_option_overrides_lib_crate_type() { + fn bin_option_overrides_lib_crate_type() { let crate = make_crate(false, true); assert!(!building_library(bin_crate, crate, false)); } #[test] - pub fn lib_option_overrides_bin_crate_type() { + fn lib_option_overrides_bin_crate_type() { let crate = make_crate(true, false); assert!(building_library(lib_crate, crate, false)); } #[test] - pub fn bin_crate_type_is_default() { + fn bin_crate_type_is_default() { let crate = make_crate(false, false); assert!(!building_library(unknown_crate, crate, false)); } #[test] - pub fn test_option_overrides_lib_crate_type() { + fn test_option_overrides_lib_crate_type() { let crate = make_crate(false, true); assert!(!building_library(unknown_crate, crate, true)); } #[test] - pub fn test_option_does_not_override_requested_lib_type() { + fn test_option_does_not_override_requested_lib_type() { let crate = make_crate(false, false); assert!(building_library(lib_crate, crate, true)); } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 585ce2dc8150..da1e4688939c 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -492,7 +492,7 @@ mod tests { use core::vec; #[test] - pub fn manually_share_arc() { + fn manually_share_arc() { let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arc_v = arc::ARC(v); @@ -517,7 +517,7 @@ pub fn manually_share_arc() { } #[test] - pub fn test_mutex_arc_condvar() { + fn test_mutex_arc_condvar() { let arc = ~MutexARC(false); let arc2 = ~arc.clone(); let (p,c) = comm::oneshot(); @@ -539,7 +539,7 @@ pub fn test_mutex_arc_condvar() { } } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_arc_condvar_poison() { + fn test_arc_condvar_poison() { let arc = ~MutexARC(1); let arc2 = ~arc.clone(); let (p, c) = comm::stream(); @@ -561,7 +561,7 @@ pub fn test_arc_condvar_poison() { } } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_mutex_arc_poison() { + fn test_mutex_arc_poison() { let arc = ~MutexARC(1); let arc2 = ~arc.clone(); do task::try || { @@ -574,7 +574,7 @@ pub fn test_mutex_arc_poison() { } } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_rw_arc_poison_wr() { + fn test_rw_arc_poison_wr() { let arc = ~RWARC(1); let arc2 = (*arc).clone(); do task::try || { @@ -587,7 +587,7 @@ pub fn test_rw_arc_poison_wr() { } } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_rw_arc_poison_ww() { + fn test_rw_arc_poison_ww() { let arc = ~RWARC(1); let arc2 = (*arc).clone(); do task::try || { @@ -600,7 +600,7 @@ pub fn test_rw_arc_poison_ww() { } } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_rw_arc_poison_dw() { + fn test_rw_arc_poison_dw() { let arc = ~RWARC(1); let arc2 = (*arc).clone(); do task::try || { @@ -615,7 +615,7 @@ pub fn test_rw_arc_poison_dw() { } } #[test] #[ignore(cfg(windows))] - pub fn test_rw_arc_no_poison_rr() { + fn test_rw_arc_no_poison_rr() { let arc = ~RWARC(1); let arc2 = (*arc).clone(); do task::try || { @@ -628,7 +628,7 @@ pub fn test_rw_arc_no_poison_rr() { } } #[test] #[ignore(cfg(windows))] - pub fn test_rw_arc_no_poison_rw() { + fn test_rw_arc_no_poison_rw() { let arc = ~RWARC(1); let arc2 = (*arc).clone(); do task::try || { @@ -641,7 +641,7 @@ pub fn test_rw_arc_no_poison_rw() { } } #[test] #[ignore(cfg(windows))] - pub fn test_rw_arc_no_poison_dr() { + fn test_rw_arc_no_poison_dr() { let arc = ~RWARC(1); let arc2 = (*arc).clone(); do task::try || { @@ -657,7 +657,7 @@ pub fn test_rw_arc_no_poison_dr() { } } #[test] - pub fn test_rw_arc() { + fn test_rw_arc() { let arc = ~RWARC(0); let arc2 = (*arc).clone(); let (p,c) = comm::stream(); @@ -694,7 +694,7 @@ pub fn test_rw_arc() { do arc.read |num| { assert!(*num == 10); } } #[test] - pub fn test_rw_downgrade() { + fn test_rw_downgrade() { // (1) A downgrader gets in write mode and does cond.wait. // (2) A writer gets in write mode, sets state to 42, and does signal. // (3) Downgrader wakes, sets state to 31337. diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 781a720b1a4d..c960c7186e3d 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -154,7 +154,7 @@ mod tests { use core::str; #[test] - pub fn test_to_base64() { + fn test_to_base64() { assert!((~"").to_base64() == ~""); assert!((~"f").to_base64() == ~"Zg=="); assert!((~"fo").to_base64() == ~"Zm8="); @@ -165,7 +165,7 @@ pub fn test_to_base64() { } #[test] - pub fn test_from_base64() { + fn test_from_base64() { assert!((~"").from_base64() == str::to_bytes(~"")); assert!((~"Zg==").from_base64() == str::to_bytes(~"f")); assert!((~"Zm8=").from_base64() == str::to_bytes(~"fo")); diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 632a38e8ca2d..d89ce4232b17 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -880,7 +880,7 @@ mod tests { static bench_bits : uint = 1 << 14; #[test] - pub fn test_to_str() { + fn test_to_str() { let zerolen = Bitv::new(0u, false); assert!(zerolen.to_str() == ~""); @@ -889,7 +889,7 @@ pub fn test_to_str() { } #[test] - pub fn test_0_elements() { + fn test_0_elements() { let mut act; let mut exp; act = Bitv::new(0u, false); @@ -898,7 +898,7 @@ pub fn test_0_elements() { } #[test] - pub fn test_1_element() { + fn test_1_element() { let mut act; act = Bitv::new(1u, false); assert!(act.eq_vec(~[0u])); @@ -907,7 +907,7 @@ pub fn test_1_element() { } #[test] - pub fn test_2_elements() { + fn test_2_elements() { let mut b = bitv::Bitv::new(2, false); b.set(0, true); b.set(1, false); @@ -915,7 +915,7 @@ pub fn test_2_elements() { } #[test] - pub fn test_10_elements() { + fn test_10_elements() { let mut act; // all 0 @@ -954,7 +954,7 @@ pub fn test_10_elements() { } #[test] - pub fn test_31_elements() { + fn test_31_elements() { let mut act; // all 0 @@ -1027,7 +1027,7 @@ pub fn test_31_elements() { } #[test] - pub fn test_32_elements() { + fn test_32_elements() { let mut act; // all 0 @@ -1102,7 +1102,7 @@ pub fn test_32_elements() { } #[test] - pub fn test_33_elements() { + fn test_33_elements() { let mut act; // all 0 @@ -1178,21 +1178,21 @@ pub fn test_33_elements() { } #[test] - pub fn test_equal_differing_sizes() { + fn test_equal_differing_sizes() { let v0 = Bitv::new(10u, false); let v1 = Bitv::new(11u, false); assert!(!v0.equal(&v1)); } #[test] - pub fn test_equal_greatly_differing_sizes() { + fn test_equal_greatly_differing_sizes() { let v0 = Bitv::new(10u, false); let v1 = Bitv::new(110u, false); assert!(!v0.equal(&v1)); } #[test] - pub fn test_equal_sneaky_small() { + fn test_equal_sneaky_small() { let mut a = bitv::Bitv::new(1, false); a.set(0, true); @@ -1203,7 +1203,7 @@ pub fn test_equal_sneaky_small() { } #[test] - pub fn test_equal_sneaky_big() { + fn test_equal_sneaky_big() { let mut a = bitv::Bitv::new(100, false); for uint::range(0, 100) |i| { a.set(i, true); @@ -1218,14 +1218,14 @@ pub fn test_equal_sneaky_big() { } #[test] - pub fn test_from_bytes() { + fn test_from_bytes() { let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); let str = ~"10110110" + ~"00000000" + ~"11111111"; assert!(bitv.to_str() == str); } #[test] - pub fn test_to_bytes() { + fn test_to_bytes() { let mut bv = Bitv::new(3, true); bv.set(1, false); assert!(bv.to_bytes() == ~[0b10100000]); @@ -1237,19 +1237,19 @@ pub fn test_to_bytes() { } #[test] - pub fn test_from_bools() { + fn test_from_bools() { assert!(from_bools([true, false, true, true]).to_str() == ~"1011"); } #[test] - pub fn test_to_bools() { + fn test_to_bools() { let bools = ~[false, false, true, false, false, true, true, false]; assert!(from_bytes([0b00100110]).to_bools() == bools); } #[test] - pub fn test_small_difference() { + fn test_small_difference() { let mut b1 = Bitv::new(3, false); let mut b2 = Bitv::new(3, false); b1.set(0, true); @@ -1263,7 +1263,7 @@ pub fn test_small_difference() { } #[test] - pub fn test_big_difference() { + fn test_big_difference() { let mut b1 = Bitv::new(100, false); let mut b2 = Bitv::new(100, false); b1.set(0, true); @@ -1277,7 +1277,7 @@ pub fn test_big_difference() { } #[test] - pub fn test_small_clear() { + fn test_small_clear() { let mut b = Bitv::new(14, true); b.clear(); for b.ones |i| { @@ -1286,7 +1286,7 @@ pub fn test_small_clear() { } #[test] - pub fn test_big_clear() { + fn test_big_clear() { let mut b = Bitv::new(140, true); b.clear(); for b.ones |i| { @@ -1295,7 +1295,7 @@ pub fn test_big_clear() { } #[test] - pub fn test_bitv_set_basic() { + fn test_bitv_set_basic() { let mut b = BitvSet::new(); assert!(b.insert(3)); assert!(!b.insert(3)); @@ -1382,7 +1382,7 @@ fn test_bitv_set_symmetric_difference() { } #[test] - pub fn test_bitv_set_union() { + fn test_bitv_set_union() { let mut a = BitvSet::new(); let mut b = BitvSet::new(); assert!(a.insert(1)); @@ -1410,7 +1410,7 @@ pub fn test_bitv_set_union() { } #[test] - pub fn test_bitv_remove() { + fn test_bitv_remove() { let mut a = BitvSet::new(); assert!(a.insert(1)); @@ -1430,7 +1430,7 @@ fn rng() -> @rand::Rng { } #[bench] - pub fn bench_uint_small(b: &mut BenchHarness) { + fn bench_uint_small(b: &mut BenchHarness) { let r = rng(); let mut bitv = 0 as uint; do b.iter { @@ -1439,7 +1439,7 @@ pub fn bench_uint_small(b: &mut BenchHarness) { } #[bench] - pub fn bench_small_bitv_small(b: &mut BenchHarness) { + fn bench_small_bitv_small(b: &mut BenchHarness) { let r = rng(); let mut bitv = SmallBitv::new(uint::bits); do b.iter { @@ -1448,7 +1448,7 @@ pub fn bench_small_bitv_small(b: &mut BenchHarness) { } #[bench] - pub fn bench_big_bitv_small(b: &mut BenchHarness) { + fn bench_big_bitv_small(b: &mut BenchHarness) { let r = rng(); let mut bitv = BigBitv::new(~[0]); do b.iter { @@ -1457,7 +1457,7 @@ pub fn bench_big_bitv_small(b: &mut BenchHarness) { } #[bench] - pub fn bench_big_bitv_big(b: &mut BenchHarness) { + fn bench_big_bitv_big(b: &mut BenchHarness) { let r = rng(); let mut storage = ~[]; storage.grow(bench_bits / uint::bits, &0); @@ -1468,7 +1468,7 @@ pub fn bench_big_bitv_big(b: &mut BenchHarness) { } #[bench] - pub fn bench_bitv_big(b: &mut BenchHarness) { + fn bench_bitv_big(b: &mut BenchHarness) { let r = rng(); let mut bitv = Bitv::new(bench_bits, false); do b.iter { @@ -1477,7 +1477,7 @@ pub fn bench_bitv_big(b: &mut BenchHarness) { } #[bench] - pub fn bench_bitv_small(b: &mut BenchHarness) { + fn bench_bitv_small(b: &mut BenchHarness) { let r = rng(); let mut bitv = Bitv::new(uint::bits, false); do b.iter { @@ -1486,7 +1486,7 @@ pub fn bench_bitv_small(b: &mut BenchHarness) { } #[bench] - pub fn bench_bitv_set_small(b: &mut BenchHarness) { + fn bench_bitv_set_small(b: &mut BenchHarness) { let r = rng(); let mut bitv = BitvSet::new(); do b.iter { @@ -1495,7 +1495,7 @@ pub fn bench_bitv_set_small(b: &mut BenchHarness) { } #[bench] - pub fn bench_bitv_set_big(b: &mut BenchHarness) { + fn bench_bitv_set_big(b: &mut BenchHarness) { let r = rng(); let mut bitv = BitvSet::new(); do b.iter { @@ -1504,7 +1504,7 @@ pub fn bench_bitv_set_big(b: &mut BenchHarness) { } #[bench] - pub fn bench_bitv_big_union(b: &mut BenchHarness) { + fn bench_bitv_big_union(b: &mut BenchHarness) { let mut b1 = Bitv::new(bench_bits, false); let mut b2 = Bitv::new(bench_bits, false); do b.iter { diff --git a/src/libstd/dlist.rs b/src/libstd/dlist.rs index a490065b835c..f9de2e0f58ad 100644 --- a/src/libstd/dlist.rs +++ b/src/libstd/dlist.rs @@ -537,7 +537,7 @@ mod tests { use core::prelude::*; #[test] - pub fn test_dlist_concat() { + fn test_dlist_concat() { let a = from_vec(~[1,2]); let b = from_vec(~[3,4]); let c = from_vec(~[5,6]); @@ -557,7 +557,7 @@ pub fn test_dlist_concat() { abcd.assert_consistent(); assert!(abcd.is_empty()); } #[test] - pub fn test_dlist_append() { + fn test_dlist_append() { let a = from_vec(~[1,2,3]); let b = from_vec(~[4,5,6]); a.append(b); @@ -573,7 +573,7 @@ pub fn test_dlist_append() { a.assert_consistent(); assert!(a.is_empty()); } #[test] - pub fn test_dlist_append_empty() { + fn test_dlist_append_empty() { let a = from_vec(~[1,2,3]); let b = DList::(); a.append(b); @@ -586,7 +586,7 @@ pub fn test_dlist_append_empty() { a.assert_consistent(); assert!(a.is_empty()); } #[test] - pub fn test_dlist_append_to_empty() { + fn test_dlist_append_to_empty() { let a = DList::(); let b = from_vec(~[4,5,6]); a.append(b); @@ -599,7 +599,7 @@ pub fn test_dlist_append_to_empty() { a.assert_consistent(); assert!(a.is_empty()); } #[test] - pub fn test_dlist_append_two_empty() { + fn test_dlist_append_two_empty() { let a = DList::(); let b = DList::(); a.append(b); @@ -611,19 +611,19 @@ pub fn test_dlist_append_two_empty() { #[test] #[ignore(cfg(windows))] #[should_fail] - pub fn test_dlist_append_self() { + fn test_dlist_append_self() { let a = DList::(); a.append(a); } #[test] #[ignore(cfg(windows))] #[should_fail] - pub fn test_dlist_prepend_self() { + fn test_dlist_prepend_self() { let a = DList::(); a.prepend(a); } #[test] - pub fn test_dlist_prepend() { + fn test_dlist_prepend() { let a = from_vec(~[1,2,3]); let b = from_vec(~[4,5,6]); b.prepend(a); @@ -639,7 +639,7 @@ pub fn test_dlist_prepend() { b.assert_consistent(); assert!(b.is_empty()); } #[test] - pub fn test_dlist_reverse() { + fn test_dlist_reverse() { let a = from_vec(~[5,4,3,2,1]); a.reverse(); assert_eq!(a.len(), 5); @@ -651,14 +651,14 @@ pub fn test_dlist_reverse() { a.assert_consistent(); assert!(a.is_empty()); } #[test] - pub fn test_dlist_reverse_empty() { + fn test_dlist_reverse_empty() { let a = DList::(); a.reverse(); assert_eq!(a.len(), 0); a.assert_consistent(); } #[test] - pub fn test_dlist_each_node() { + fn test_dlist_each_node() { let a = from_vec(~[1,2,4,5]); for a.each_node |nobe| { if nobe.data > 3 { @@ -675,28 +675,28 @@ pub fn test_dlist_each_node() { a.assert_consistent(); assert!(a.is_empty()); } #[test] - pub fn test_dlist_clear() { + fn test_dlist_clear() { let a = from_vec(~[5,4,3,2,1]); a.clear(); assert_eq!(a.len(), 0); a.assert_consistent(); } #[test] - pub fn test_dlist_is_empty() { + fn test_dlist_is_empty() { let empty = DList::(); let full1 = from_vec(~[1,2,3]); assert!(empty.is_empty()); assert!(!full1.is_empty()); } #[test] - pub fn test_dlist_head_tail() { + fn test_dlist_head_tail() { let l = from_vec(~[1,2,3]); assert_eq!(l.head(), 1); assert_eq!(l.tail(), 3); assert_eq!(l.len(), 3); } #[test] - pub fn test_dlist_pop() { + fn test_dlist_pop() { let l = from_vec(~[1,2,3]); assert_eq!(l.pop().get(), 1); assert_eq!(l.tail(), 3); @@ -709,7 +709,7 @@ pub fn test_dlist_pop() { assert!(l.pop().is_none()); } #[test] - pub fn test_dlist_pop_tail() { + fn test_dlist_pop_tail() { let l = from_vec(~[1,2,3]); assert_eq!(l.pop_tail().get(), 3); assert_eq!(l.tail(), 2); @@ -722,7 +722,7 @@ pub fn test_dlist_pop_tail() { assert!(l.pop_tail().is_none()); } #[test] - pub fn test_dlist_push() { + fn test_dlist_push() { let l = DList::(); l.push(1); assert_eq!(l.head(), 1); @@ -736,7 +736,7 @@ pub fn test_dlist_push() { assert_eq!(l.len(), 3); } #[test] - pub fn test_dlist_push_head() { + fn test_dlist_push_head() { let l = DList::(); l.push_head(3); assert_eq!(l.head(), 3); @@ -750,12 +750,12 @@ pub fn test_dlist_push_head() { assert_eq!(l.len(), 3); } #[test] - pub fn test_dlist_foldl() { + fn test_dlist_foldl() { let l = from_vec(vec::from_fn(101, |x|x)); assert_eq!(iter::foldl(&l, 0, |accum,elem| *accum+*elem), 5050); } #[test] - pub fn test_dlist_break_early() { + fn test_dlist_break_early() { let l = from_vec(~[1,2,3,4,5]); let mut x = 0; for l.each |i| { @@ -765,7 +765,7 @@ pub fn test_dlist_break_early() { assert_eq!(x, 3); } #[test] - pub fn test_dlist_remove_head() { + fn test_dlist_remove_head() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); @@ -780,7 +780,7 @@ pub fn test_dlist_remove_head() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_remove_mid() { + fn test_dlist_remove_mid() { let l = DList::(); l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); @@ -795,7 +795,7 @@ pub fn test_dlist_remove_mid() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_remove_tail() { + fn test_dlist_remove_tail() { let l = DList::(); l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); @@ -810,7 +810,7 @@ pub fn test_dlist_remove_tail() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_remove_one_two() { + fn test_dlist_remove_one_two() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); @@ -826,7 +826,7 @@ pub fn test_dlist_remove_one_two() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_remove_one_three() { + fn test_dlist_remove_one_three() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); @@ -841,7 +841,7 @@ pub fn test_dlist_remove_one_three() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_remove_two_three() { + fn test_dlist_remove_two_three() { let l = DList::(); l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); @@ -856,7 +856,7 @@ pub fn test_dlist_remove_two_three() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_remove_all() { + fn test_dlist_remove_all() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); @@ -869,7 +869,7 @@ pub fn test_dlist_remove_all() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_insert_n_before() { + fn test_dlist_insert_n_before() { let l = DList::(); l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); @@ -885,7 +885,7 @@ pub fn test_dlist_insert_n_before() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_insert_n_after() { + fn test_dlist_insert_n_after() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); @@ -901,7 +901,7 @@ pub fn test_dlist_insert_n_after() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_insert_before_head() { + fn test_dlist_insert_before_head() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); @@ -916,7 +916,7 @@ pub fn test_dlist_insert_before_head() { l.assert_consistent(); assert!(l.is_empty()); } #[test] - pub fn test_dlist_insert_after_tail() { + fn test_dlist_insert_after_tail() { let l = DList::(); l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); @@ -931,7 +931,7 @@ pub fn test_dlist_insert_after_tail() { l.assert_consistent(); assert!(l.is_empty()); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_asymmetric_link() { + fn test_dlist_asymmetric_link() { let l = DList::(); let _one = l.push_n(1); let two = l.push_n(2); @@ -939,7 +939,7 @@ pub fn test_dlist_asymmetric_link() { l.assert_consistent(); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_cyclic_list() { + fn test_dlist_cyclic_list() { let l = DList::(); let one = l.push_n(1); let _two = l.push_n(2); @@ -949,32 +949,32 @@ pub fn test_dlist_cyclic_list() { l.assert_consistent(); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_headless() { + fn test_dlist_headless() { DList::().head(); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_insert_already_present_before() { + fn test_dlist_insert_already_present_before() { let l = DList::(); let one = l.push_n(1); let two = l.push_n(2); l.insert_n_before(two, one); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_insert_already_present_after() { + fn test_dlist_insert_already_present_after() { let l = DList::(); let one = l.push_n(1); let two = l.push_n(2); l.insert_n_after(one, two); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_insert_before_orphan() { + fn test_dlist_insert_before_orphan() { let l = DList::(); let one = new_dlist_node(1); let two = new_dlist_node(2); l.insert_n_before(one, two); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_dlist_insert_after_orphan() { + fn test_dlist_insert_after_orphan() { let l = DList::(); let one = new_dlist_node(1); let two = new_dlist_node(2); diff --git a/src/libstd/future.rs b/src/libstd/future.rs index feea8fb4fcda..a36f67fc95a0 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -172,7 +172,7 @@ pub fn spawn(blk: ~fn() -> A) -> Future { #[allow(non_implicitly_copyable_typarams)] #[cfg(test)] -pub mod test { +mod test { use core::prelude::*; use future::*; @@ -181,13 +181,13 @@ pub mod test { use core::task; #[test] - pub fn test_from_value() { + fn test_from_value() { let f = from_value(~"snail"); assert!(f.get() == ~"snail"); } #[test] - pub fn test_from_port() { + fn test_from_port() { let (ch, po) = oneshot::init(); send_one(ch, ~"whale"); let f = from_port(po); @@ -195,25 +195,25 @@ pub fn test_from_port() { } #[test] - pub fn test_from_fn() { + fn test_from_fn() { let f = from_fn(|| ~"brail"); assert!(f.get() == ~"brail"); } #[test] - pub fn test_interface_get() { + fn test_interface_get() { let f = from_value(~"fail"); assert!(f.get() == ~"fail"); } #[test] - pub fn test_get_ref_method() { + fn test_get_ref_method() { let f = from_value(22); assert!(*f.get_ref() == 22); } #[test] - pub fn test_spawn() { + fn test_spawn() { let f = spawn(|| ~"bale"); assert!(f.get() == ~"bale"); } @@ -221,13 +221,13 @@ pub fn test_spawn() { #[test] #[should_fail] #[ignore(cfg(target_os = "win32"))] - pub fn test_futurefail() { + fn test_futurefail() { let f = spawn(|| fail!()); let _x: ~str = f.get(); } #[test] - pub fn test_sendable_future() { + fn test_sendable_future() { let expected = ~"schlorf"; let f = do spawn { copy expected }; do task::spawn || { diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index b1e80718d8f7..d710a7b87354 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -662,7 +662,7 @@ mod tests { use core::result::{Err, Ok}; use core::result; - pub fn check_fail_type(f: Fail_, ft: FailType) { + fn check_fail_type(f: Fail_, ft: FailType) { match f { ArgumentMissing(_) => assert!(ft == ArgumentMissing_), UnrecognizedOption(_) => assert!(ft == UnrecognizedOption_), @@ -675,7 +675,7 @@ pub fn check_fail_type(f: Fail_, ft: FailType) { // Tests for reqopt #[test] - pub fn test_reqopt_long() { + fn test_reqopt_long() { let args = ~[~"--test=20"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); @@ -689,7 +689,7 @@ pub fn test_reqopt_long() { } #[test] - pub fn test_reqopt_long_missing() { + fn test_reqopt_long_missing() { let args = ~[~"blah"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); @@ -700,7 +700,7 @@ pub fn test_reqopt_long_missing() { } #[test] - pub fn test_reqopt_long_no_arg() { + fn test_reqopt_long_no_arg() { let args = ~[~"--test"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); @@ -711,7 +711,7 @@ pub fn test_reqopt_long_no_arg() { } #[test] - pub fn test_reqopt_long_multi() { + fn test_reqopt_long_multi() { let args = ~[~"--test=20", ~"--test=30"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); @@ -722,7 +722,7 @@ pub fn test_reqopt_long_multi() { } #[test] - pub fn test_reqopt_short() { + fn test_reqopt_short() { let args = ~[~"-t", ~"20"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); @@ -736,7 +736,7 @@ pub fn test_reqopt_short() { } #[test] - pub fn test_reqopt_short_missing() { + fn test_reqopt_short_missing() { let args = ~[~"blah"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); @@ -747,7 +747,7 @@ pub fn test_reqopt_short_missing() { } #[test] - pub fn test_reqopt_short_no_arg() { + fn test_reqopt_short_no_arg() { let args = ~[~"-t"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); @@ -758,7 +758,7 @@ pub fn test_reqopt_short_no_arg() { } #[test] - pub fn test_reqopt_short_multi() { + fn test_reqopt_short_multi() { let args = ~[~"-t", ~"20", ~"-t", ~"30"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); @@ -771,7 +771,7 @@ pub fn test_reqopt_short_multi() { // Tests for optopt #[test] - pub fn test_optopt_long() { + fn test_optopt_long() { let args = ~[~"--test=20"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); @@ -785,7 +785,7 @@ pub fn test_optopt_long() { } #[test] - pub fn test_optopt_long_missing() { + fn test_optopt_long_missing() { let args = ~[~"blah"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); @@ -796,7 +796,7 @@ pub fn test_optopt_long_missing() { } #[test] - pub fn test_optopt_long_no_arg() { + fn test_optopt_long_no_arg() { let args = ~[~"--test"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); @@ -807,7 +807,7 @@ pub fn test_optopt_long_no_arg() { } #[test] - pub fn test_optopt_long_multi() { + fn test_optopt_long_multi() { let args = ~[~"--test=20", ~"--test=30"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); @@ -818,7 +818,7 @@ pub fn test_optopt_long_multi() { } #[test] - pub fn test_optopt_short() { + fn test_optopt_short() { let args = ~[~"-t", ~"20"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); @@ -832,7 +832,7 @@ pub fn test_optopt_short() { } #[test] - pub fn test_optopt_short_missing() { + fn test_optopt_short_missing() { let args = ~[~"blah"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); @@ -843,7 +843,7 @@ pub fn test_optopt_short_missing() { } #[test] - pub fn test_optopt_short_no_arg() { + fn test_optopt_short_no_arg() { let args = ~[~"-t"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); @@ -854,7 +854,7 @@ pub fn test_optopt_short_no_arg() { } #[test] - pub fn test_optopt_short_multi() { + fn test_optopt_short_multi() { let args = ~[~"-t", ~"20", ~"-t", ~"30"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); @@ -867,7 +867,7 @@ pub fn test_optopt_short_multi() { // Tests for optflag #[test] - pub fn test_optflag_long() { + fn test_optflag_long() { let args = ~[~"--test"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); @@ -878,7 +878,7 @@ pub fn test_optflag_long() { } #[test] - pub fn test_optflag_long_missing() { + fn test_optflag_long_missing() { let args = ~[~"blah"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); @@ -889,7 +889,7 @@ pub fn test_optflag_long_missing() { } #[test] - pub fn test_optflag_long_arg() { + fn test_optflag_long_arg() { let args = ~[~"--test=20"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); @@ -903,7 +903,7 @@ pub fn test_optflag_long_arg() { } #[test] - pub fn test_optflag_long_multi() { + fn test_optflag_long_multi() { let args = ~[~"--test", ~"--test"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); @@ -914,7 +914,7 @@ pub fn test_optflag_long_multi() { } #[test] - pub fn test_optflag_short() { + fn test_optflag_short() { let args = ~[~"-t"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); @@ -925,7 +925,7 @@ pub fn test_optflag_short() { } #[test] - pub fn test_optflag_short_missing() { + fn test_optflag_short_missing() { let args = ~[~"blah"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); @@ -936,7 +936,7 @@ pub fn test_optflag_short_missing() { } #[test] - pub fn test_optflag_short_arg() { + fn test_optflag_short_arg() { let args = ~[~"-t", ~"20"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); @@ -951,7 +951,7 @@ pub fn test_optflag_short_arg() { } #[test] - pub fn test_optflag_short_multi() { + fn test_optflag_short_multi() { let args = ~[~"-t", ~"-t"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); @@ -963,7 +963,7 @@ pub fn test_optflag_short_multi() { // Tests for optflagmulti #[test] - pub fn test_optflagmulti_short1() { + fn test_optflagmulti_short1() { let args = ~[~"-v"]; let opts = ~[optflagmulti(~"v")]; let rs = getopts(args, opts); @@ -976,7 +976,7 @@ pub fn test_optflagmulti_short1() { } #[test] - pub fn test_optflagmulti_short2a() { + fn test_optflagmulti_short2a() { let args = ~[~"-v", ~"-v"]; let opts = ~[optflagmulti(~"v")]; let rs = getopts(args, opts); @@ -989,7 +989,7 @@ pub fn test_optflagmulti_short2a() { } #[test] - pub fn test_optflagmulti_short2b() { + fn test_optflagmulti_short2b() { let args = ~[~"-vv"]; let opts = ~[optflagmulti(~"v")]; let rs = getopts(args, opts); @@ -1002,7 +1002,7 @@ pub fn test_optflagmulti_short2b() { } #[test] - pub fn test_optflagmulti_long1() { + fn test_optflagmulti_long1() { let args = ~[~"--verbose"]; let opts = ~[optflagmulti(~"verbose")]; let rs = getopts(args, opts); @@ -1015,7 +1015,7 @@ pub fn test_optflagmulti_long1() { } #[test] - pub fn test_optflagmulti_long2() { + fn test_optflagmulti_long2() { let args = ~[~"--verbose", ~"--verbose"]; let opts = ~[optflagmulti(~"verbose")]; let rs = getopts(args, opts); @@ -1029,7 +1029,7 @@ pub fn test_optflagmulti_long2() { // Tests for optmulti #[test] - pub fn test_optmulti_long() { + fn test_optmulti_long() { let args = ~[~"--test=20"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); @@ -1043,7 +1043,7 @@ pub fn test_optmulti_long() { } #[test] - pub fn test_optmulti_long_missing() { + fn test_optmulti_long_missing() { let args = ~[~"blah"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); @@ -1054,7 +1054,7 @@ pub fn test_optmulti_long_missing() { } #[test] - pub fn test_optmulti_long_no_arg() { + fn test_optmulti_long_no_arg() { let args = ~[~"--test"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); @@ -1065,7 +1065,7 @@ pub fn test_optmulti_long_no_arg() { } #[test] - pub fn test_optmulti_long_multi() { + fn test_optmulti_long_multi() { let args = ~[~"--test=20", ~"--test=30"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); @@ -1082,7 +1082,7 @@ pub fn test_optmulti_long_multi() { } #[test] - pub fn test_optmulti_short() { + fn test_optmulti_short() { let args = ~[~"-t", ~"20"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); @@ -1096,7 +1096,7 @@ pub fn test_optmulti_short() { } #[test] - pub fn test_optmulti_short_missing() { + fn test_optmulti_short_missing() { let args = ~[~"blah"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); @@ -1107,7 +1107,7 @@ pub fn test_optmulti_short_missing() { } #[test] - pub fn test_optmulti_short_no_arg() { + fn test_optmulti_short_no_arg() { let args = ~[~"-t"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); @@ -1118,7 +1118,7 @@ pub fn test_optmulti_short_no_arg() { } #[test] - pub fn test_optmulti_short_multi() { + fn test_optmulti_short_multi() { let args = ~[~"-t", ~"20", ~"-t", ~"30"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); @@ -1135,7 +1135,7 @@ pub fn test_optmulti_short_multi() { } #[test] - pub fn test_unrecognized_option_long() { + fn test_unrecognized_option_long() { let args = ~[~"--untest"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); @@ -1146,7 +1146,7 @@ pub fn test_unrecognized_option_long() { } #[test] - pub fn test_unrecognized_option_short() { + fn test_unrecognized_option_short() { let args = ~[~"-t"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); @@ -1157,7 +1157,7 @@ pub fn test_unrecognized_option_short() { } #[test] - pub fn test_combined() { + fn test_combined() { let args = ~[~"prog", ~"free1", ~"-s", ~"20", ~"free2", ~"--flag", ~"--long=30", ~"-f", ~"-m", ~"40", @@ -1189,7 +1189,7 @@ pub fn test_combined() { } #[test] - pub fn test_multi() { + fn test_multi() { let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"]; let opts = ~[optopt(~"e"), optopt(~"encrypt"), optopt(~"f")]; let matches = &match getopts(args, opts) { @@ -1211,7 +1211,7 @@ pub fn test_multi() { } #[test] - pub fn test_nospace() { + fn test_nospace() { let args = ~[~"-Lfoo", ~"-M."]; let opts = ~[optmulti(~"L"), optmulti(~"M")]; let matches = &match getopts(args, opts) { @@ -1226,7 +1226,7 @@ pub fn test_nospace() { } #[test] - pub fn test_groups_reqopt() { + fn test_groups_reqopt() { let opt = groups::reqopt(~"b", ~"banana", ~"some bananas", ~"VAL"); assert!(opt == OptGroup { short_name: ~"b", long_name: ~"banana", @@ -1237,7 +1237,7 @@ pub fn test_groups_reqopt() { } #[test] - pub fn test_groups_optopt() { + fn test_groups_optopt() { let opt = groups::optopt(~"a", ~"apple", ~"some apples", ~"VAL"); assert!(opt == OptGroup { short_name: ~"a", long_name: ~"apple", @@ -1248,7 +1248,7 @@ pub fn test_groups_optopt() { } #[test] - pub fn test_groups_optflag() { + fn test_groups_optflag() { let opt = groups::optflag(~"k", ~"kiwi", ~"some kiwis"); assert!(opt == OptGroup { short_name: ~"k", long_name: ~"kiwi", @@ -1259,7 +1259,7 @@ pub fn test_groups_optflag() { } #[test] - pub fn test_groups_optflagopt() { + fn test_groups_optflagopt() { let opt = groups::optflagopt(~"p", ~"pineapple", ~"some pineapples", ~"VAL"); assert!(opt == OptGroup { short_name: ~"p", @@ -1271,7 +1271,7 @@ pub fn test_groups_optflagopt() { } #[test] - pub fn test_groups_optmulti() { + fn test_groups_optmulti() { let opt = groups::optmulti(~"l", ~"lime", ~"some limes", ~"VAL"); assert!(opt == OptGroup { short_name: ~"l", @@ -1283,7 +1283,7 @@ pub fn test_groups_optmulti() { } #[test] - pub fn test_groups_long_to_short() { + fn test_groups_long_to_short() { let short = ~[reqopt(~"b"), reqopt(~"banana")]; let verbose = groups::reqopt(~"b", ~"banana", ~"some bananas", ~"VAL"); @@ -1292,7 +1292,7 @@ pub fn test_groups_long_to_short() { } #[test] - pub fn test_groups_getopts() { + fn test_groups_getopts() { let short = ~[ reqopt(~"b"), reqopt(~"banana"), optopt(~"a"), optopt(~"apple"), @@ -1318,7 +1318,7 @@ pub fn test_groups_getopts() { } #[test] - pub fn test_groups_usage() { + fn test_groups_usage() { let optgroups = ~[ groups::reqopt(~"b", ~"banana", ~"Desc", ~"VAL"), groups::optopt(~"a", ~"012345678901234567890123456789", @@ -1349,7 +1349,7 @@ pub fn test_groups_usage() { } #[test] - pub fn test_groups_usage_description_wrapping() { + fn test_groups_usage_description_wrapping() { // indentation should be 24 spaces // lines wrap after 78: or rather descriptions wrap after 54 diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 63d461ed4d3b..8e173ff8a9c6 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -160,7 +160,7 @@ mod tests { use core::option; #[test] - pub fn test_is_empty() { + fn test_is_empty() { let empty : @list::List = from_vec(~[]); let full1 = from_vec(~[1]); let full2 = from_vec(~['r', 'u']); @@ -171,7 +171,7 @@ pub fn test_is_empty() { } #[test] - pub fn test_from_vec() { + fn test_from_vec() { let l = from_vec(~[0, 1, 2]); assert!((head(l) == 0)); @@ -184,13 +184,13 @@ pub fn test_from_vec() { } #[test] - pub fn test_from_vec_empty() { + fn test_from_vec_empty() { let empty : @list::List = from_vec(~[]); assert!((empty == @list::Nil::)); } #[test] - pub fn test_foldl() { + fn test_foldl() { fn add(a: &uint, b: &int) -> uint { return *a + (*b as uint); } let l = from_vec(~[0, 1, 2, 3, 4]); let empty = @list::Nil::; @@ -199,7 +199,7 @@ pub fn test_foldl() { } #[test] - pub fn test_foldl2() { + fn test_foldl2() { fn sub(a: &int, b: &int) -> int { *a - *b } @@ -208,14 +208,14 @@ fn sub(a: &int, b: &int) -> int { } #[test] - pub fn test_find_success() { + fn test_find_success() { fn match_(i: &int) -> bool { return *i == 2; } let l = from_vec(~[0, 1, 2]); assert!((list::find(l, match_) == option::Some(2))); } #[test] - pub fn test_find_fail() { + fn test_find_fail() { fn match_(_i: &int) -> bool { return false; } let l = from_vec(~[0, 1, 2]); let empty = @list::Nil::; @@ -224,7 +224,7 @@ pub fn test_find_fail() { } #[test] - pub fn test_has() { + fn test_has() { let l = from_vec(~[5, 8, 6]); let empty = @list::Nil::; assert!((list::has(l, 5))); @@ -234,7 +234,7 @@ pub fn test_has() { } #[test] - pub fn test_len() { + fn test_len() { let l = from_vec(~[0, 1, 2]); let empty = @list::Nil::; assert!((list::len(l) == 3u)); @@ -242,7 +242,7 @@ pub fn test_len() { } #[test] - pub fn test_append() { + fn test_append() { assert!(from_vec(~[1,2,3,4]) == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4]))); } diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index a8b2723bcfbc..b32df75063d9 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -1426,7 +1426,7 @@ struct TcpBufferedSocketData { } #[cfg(test)] -pub mod test { +mod test { use net::ip; use net::tcp::{GenericListenErr, TcpConnectErrData, TcpListenErrData}; use net::tcp::{connect, accept, read, listen, TcpSocket, socket_buf}; @@ -1447,9 +1447,9 @@ pub mod test { #[cfg(target_os="darwin")] #[cfg(target_os="linux")] #[cfg(target_os="android")] - pub mod tcp_ipv4_server_and_client_test { + mod tcp_ipv4_server_and_client_test { #[cfg(target_arch="x86_64")] - pub mod impl64 { + mod impl64 { use net::tcp::test::*; #[test] @@ -1497,7 +1497,7 @@ fn test_tcp_socket_impl_reader_handles_eof() { #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] #[cfg(target_arch="mips")] - pub mod impl32 { + mod impl32 { use net::tcp::test::*; #[test] diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 9b8b0f9be0bc..4cb9a98036b1 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -810,7 +810,7 @@ mod tests { use core::hashmap::HashMap; #[test] - pub fn test_url_parse() { + fn test_url_parse() { let url = ~"http://user:pass@rust-lang.org/doc?s=v#something"; let up = from_str(url); @@ -826,7 +826,7 @@ pub fn test_url_parse() { } #[test] - pub fn test_url_parse_host_slash() { + fn test_url_parse_host_slash() { let urlstr = ~"http://0.42.42.42/"; let url = from_str(urlstr).unwrap(); assert!(url.host == ~"0.42.42.42"); @@ -834,87 +834,87 @@ pub fn test_url_parse_host_slash() { } #[test] - pub fn test_url_with_underscores() { + fn test_url_with_underscores() { let urlstr = ~"http://dotcom.com/file_name.html"; let url = from_str(urlstr).unwrap(); assert!(url.path == ~"/file_name.html"); } #[test] - pub fn test_url_with_dashes() { + fn test_url_with_dashes() { let urlstr = ~"http://dotcom.com/file-name.html"; let url = from_str(urlstr).unwrap(); assert!(url.path == ~"/file-name.html"); } #[test] - pub fn test_no_scheme() { + fn test_no_scheme() { assert!(get_scheme("noschemehere.html").is_err()); } #[test] - pub fn test_invalid_scheme_errors() { + fn test_invalid_scheme_errors() { assert!(from_str("99://something").is_err()); assert!(from_str("://something").is_err()); } #[test] - pub fn test_full_url_parse_and_format() { + fn test_full_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?s=v#something"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_userless_url_parse_and_format() { + fn test_userless_url_parse_and_format() { let url = ~"http://rust-lang.org/doc?s=v#something"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_queryless_url_parse_and_format() { + fn test_queryless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc#something"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_empty_query_url_parse_and_format() { + fn test_empty_query_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?#something"; let should_be = ~"http://user:pass@rust-lang.org/doc#something"; assert!(from_str(url).unwrap().to_str() == should_be); } #[test] - pub fn test_fragmentless_url_parse_and_format() { + fn test_fragmentless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?q=v"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_minimal_url_parse_and_format() { + fn test_minimal_url_parse_and_format() { let url = ~"http://rust-lang.org/doc"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_scheme_host_only_url_parse_and_format() { + fn test_scheme_host_only_url_parse_and_format() { let url = ~"http://rust-lang.org"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_pathless_url_parse_and_format() { + fn test_pathless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org?q=v#something"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_scheme_host_fragment_only_url_parse_and_format() { + fn test_scheme_host_fragment_only_url_parse_and_format() { let url = ~"http://rust-lang.org#something"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_url_component_encoding() { + fn test_url_component_encoding() { let url = ~"http://rust-lang.org/doc%20uments?ba%25d%20=%23%26%2B"; let u = from_str(url).unwrap(); assert!(u.path == ~"/doc uments"); @@ -922,13 +922,13 @@ pub fn test_url_component_encoding() { } #[test] - pub fn test_url_without_authority() { + fn test_url_without_authority() { let url = ~"mailto:test@email.com"; assert!(from_str(url).unwrap().to_str() == url); } #[test] - pub fn test_encode() { + fn test_encode() { assert!(encode("") == ~""); assert!(encode("http://example.com") == ~"http://example.com"); assert!(encode("foo bar% baz") == ~"foo%20bar%25%20baz"); @@ -956,7 +956,7 @@ pub fn test_encode() { } #[test] - pub fn test_encode_component() { + fn test_encode_component() { assert!(encode_component("") == ~""); assert!(encode_component("http://example.com") == ~"http%3A%2F%2Fexample.com"); @@ -985,7 +985,7 @@ pub fn test_encode_component() { } #[test] - pub fn test_decode() { + fn test_decode() { assert!(decode("") == ~""); assert!(decode("abc/def 123") == ~"abc/def 123"); assert!(decode("abc%2Fdef%20123") == ~"abc%2Fdef 123"); @@ -1013,7 +1013,7 @@ pub fn test_decode() { } #[test] - pub fn test_decode_component() { + fn test_decode_component() { assert!(decode_component("") == ~""); assert!(decode_component("abc/def 123") == ~"abc/def 123"); assert!(decode_component("abc%2Fdef%20123") == ~"abc/def 123"); @@ -1041,7 +1041,7 @@ pub fn test_decode_component() { } #[test] - pub fn test_encode_form_urlencoded() { + fn test_encode_form_urlencoded() { let mut m = HashMap::new(); assert!(encode_form_urlencoded(&m) == ~""); @@ -1060,7 +1060,7 @@ pub fn test_encode_form_urlencoded() { } #[test] - pub fn test_decode_form_urlencoded() { + fn test_decode_form_urlencoded() { // FIXME #4449: Commented out because this causes an ICE, but only // on FreeBSD /* diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index f5f7f5e326a7..6aa4d1c54bc9 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -282,7 +282,7 @@ mod tests { use core::vec; #[test] - pub fn test() { + fn test() { struct Test { input: ~str, output: ~[u8], diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 39ca9bb5ba66..72a888fcc917 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -733,7 +733,7 @@ mod test_qsort3 { use core::vec; - pub fn check_sort(v1: &mut [int], v2: &mut [int]) { + fn check_sort(v1: &mut [int], v2: &mut [int]) { let len = vec::len::(v1); quick_sort3::(v1); let mut i = 0; @@ -745,7 +745,7 @@ pub fn check_sort(v1: &mut [int], v2: &mut [int]) { } #[test] - pub fn test() { + fn test() { { let mut v1 = ~[3, 7, 4, 5, 2, 9, 5, 8]; let mut v2 = ~[2, 3, 4, 5, 5, 7, 8, 9]; @@ -777,7 +777,7 @@ mod test_qsort { use core::int; use core::vec; - pub fn check_sort(v1: &mut [int], v2: &mut [int]) { + fn check_sort(v1: &mut [int], v2: &mut [int]) { let len = vec::len::(v1); fn leual(a: &int, b: &int) -> bool { *a <= *b } quick_sort::(v1, leual); @@ -790,7 +790,7 @@ fn leual(a: &int, b: &int) -> bool { *a <= *b } } #[test] - pub fn test() { + fn test() { { let mut v1 = ~[3, 7, 4, 5, 2, 9, 5, 8]; let mut v2 = ~[2, 3, 4, 5, 5, 7, 8, 9]; @@ -816,7 +816,7 @@ pub fn test() { // Regression test for #750 #[test] - pub fn test_simple() { + fn test_simple() { let mut names = ~[2, 1, 3]; let expected = ~[1, 2, 3]; @@ -842,7 +842,7 @@ mod tests { use core::vec; - pub fn check_sort(v1: &[int], v2: &[int]) { + fn check_sort(v1: &[int], v2: &[int]) { let len = vec::len::(v1); pub fn le(a: &int, b: &int) -> bool { *a <= *b } let f = le; @@ -856,7 +856,7 @@ pub fn le(a: &int, b: &int) -> bool { *a <= *b } } #[test] - pub fn test() { + fn test() { { let v1 = ~[3, 7, 4, 5, 2, 9, 5, 8]; let v2 = ~[2, 3, 4, 5, 5, 7, 8, 9]; @@ -873,7 +873,7 @@ pub fn test() { } #[test] - pub fn test_merge_sort_mutable() { + fn test_merge_sort_mutable() { pub fn le(a: &int, b: &int) -> bool { *a <= *b } let mut v1 = ~[3, 2, 1]; let v2 = merge_sort(v1, le); @@ -881,7 +881,7 @@ pub fn le(a: &int, b: &int) -> bool { *a <= *b } } #[test] - pub fn test_merge_sort_stability() { + fn test_merge_sort_stability() { // tjc: funny that we have to use parens fn ile(x: &(&'static str), y: &(&'static str)) -> bool { diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index f2de8213a1b9..971bb51f7e9f 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -728,19 +728,19 @@ mod tests { * Semaphore tests ************************************************************************/ #[test] - pub fn test_sem_acquire_release() { + fn test_sem_acquire_release() { let s = ~semaphore(1); s.acquire(); s.release(); s.acquire(); } #[test] - pub fn test_sem_basic() { + fn test_sem_basic() { let s = ~semaphore(1); do s.access { } } #[test] - pub fn test_sem_as_mutex() { + fn test_sem_as_mutex() { let s = ~semaphore(1); let s2 = ~s.clone(); do task::spawn || { @@ -753,7 +753,7 @@ pub fn test_sem_as_mutex() { } } #[test] - pub fn test_sem_as_cvar() { + fn test_sem_as_cvar() { /* Child waits and parent signals */ let (p,c) = comm::stream(); let s = ~semaphore(0); @@ -779,7 +779,7 @@ pub fn test_sem_as_cvar() { c.send(()); } #[test] - pub fn test_sem_multi_resource() { + fn test_sem_multi_resource() { // Parent and child both get in the critical section at the same // time, and shake hands. let s = ~semaphore(2); @@ -798,7 +798,7 @@ pub fn test_sem_multi_resource() { } } #[test] - pub fn test_sem_runtime_friendly_blocking() { + fn test_sem_runtime_friendly_blocking() { // Force the runtime to schedule two threads on the same sched_loop. // When one blocks, it should schedule the other one. do task::spawn_sched(task::ManualThreads(1)) { @@ -823,7 +823,7 @@ pub fn test_sem_runtime_friendly_blocking() { * Mutex tests ************************************************************************/ #[test] - pub fn test_mutex_lock() { + fn test_mutex_lock() { // Unsafely achieve shared state, and do the textbook // "load tmp = move ptr; inc tmp; store ptr <- tmp" dance. let (p,c) = comm::stream(); @@ -854,7 +854,7 @@ fn access_shared(sharedstate: &mut int, m: &Mutex, n: uint) { } } #[test] - pub fn test_mutex_cond_wait() { + fn test_mutex_cond_wait() { let m = ~Mutex(); // Child wakes up parent @@ -886,7 +886,7 @@ pub fn test_mutex_cond_wait() { let _ = port.recv(); // Wait until child wakes up } #[cfg(test)] - pub fn test_mutex_cond_broadcast_helper(num_waiters: uint) { + fn test_mutex_cond_broadcast_helper(num_waiters: uint) { let m = ~Mutex(); let mut ports = ~[]; @@ -913,15 +913,15 @@ pub fn test_mutex_cond_broadcast_helper(num_waiters: uint) { for ports.each |port| { let _ = port.recv(); } } #[test] - pub fn test_mutex_cond_broadcast() { + fn test_mutex_cond_broadcast() { test_mutex_cond_broadcast_helper(12); } #[test] - pub fn test_mutex_cond_broadcast_none() { + fn test_mutex_cond_broadcast_none() { test_mutex_cond_broadcast_helper(0); } #[test] - pub fn test_mutex_cond_no_waiter() { + fn test_mutex_cond_no_waiter() { let m = ~Mutex(); let m2 = ~m.clone(); do task::try || { @@ -932,7 +932,7 @@ pub fn test_mutex_cond_no_waiter() { } } #[test] #[ignore(cfg(windows))] - pub fn test_mutex_killed_simple() { + fn test_mutex_killed_simple() { // Mutex must get automatically unlocked if failed/killed within. let m = ~Mutex(); let m2 = ~m.clone(); @@ -947,7 +947,7 @@ pub fn test_mutex_killed_simple() { do m.lock { } } #[test] #[ignore(cfg(windows))] - pub fn test_mutex_killed_cond() { + fn test_mutex_killed_cond() { // Getting killed during cond wait must not corrupt the mutex while // unwinding (e.g. double unlock). let m = ~Mutex(); @@ -973,7 +973,7 @@ pub fn test_mutex_killed_cond() { } } #[test] #[ignore(cfg(windows))] - pub fn test_mutex_killed_broadcast() { + fn test_mutex_killed_broadcast() { let m = ~Mutex(); let m2 = ~m.clone(); let (p,c) = comm::stream(); @@ -1026,7 +1026,7 @@ fn SendOnFailure(c: comm::Chan<()>) -> SendOnFailure { } } #[test] - pub fn test_mutex_cond_signal_on_0() { + fn test_mutex_cond_signal_on_0() { // Tests that signal_on(0) is equivalent to signal(). let m = ~Mutex(); do m.lock_cond |cond| { @@ -1040,7 +1040,7 @@ pub fn test_mutex_cond_signal_on_0() { } } #[test] #[ignore(cfg(windows))] - pub fn test_mutex_different_conds() { + fn test_mutex_different_conds() { let result = do task::try { let m = ~mutex_with_condvars(2); let m2 = ~m.clone(); @@ -1061,7 +1061,7 @@ pub fn test_mutex_different_conds() { assert!(result.is_err()); } #[test] #[ignore(cfg(windows))] - pub fn test_mutex_no_condvars() { + fn test_mutex_no_condvars() { let result = do task::try { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.wait(); } @@ -1084,7 +1084,7 @@ pub fn test_mutex_no_condvars() { #[cfg(test)] pub enum RWlockMode { Read, Write, Downgrade, DowngradeRead } #[cfg(test)] - pub fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: &fn()) { + fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: &fn()) { match mode { Read => x.read(blk), Write => x.write(blk), @@ -1100,7 +1100,7 @@ pub fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: &fn()) { } } #[cfg(test)] - pub fn test_rwlock_exclusion(x: ~RWlock, + fn test_rwlock_exclusion(x: ~RWlock, mode1: RWlockMode, mode2: RWlockMode) { // Test mutual exclusion between readers and writers. Just like the @@ -1132,21 +1132,21 @@ fn access_shared(sharedstate: &mut int, x: &RWlock, mode: RWlockMode, } } #[test] - pub fn test_rwlock_readers_wont_modify_the_data() { + fn test_rwlock_readers_wont_modify_the_data() { test_rwlock_exclusion(~RWlock(), Read, Write); test_rwlock_exclusion(~RWlock(), Write, Read); test_rwlock_exclusion(~RWlock(), Read, Downgrade); test_rwlock_exclusion(~RWlock(), Downgrade, Read); } #[test] - pub fn test_rwlock_writers_and_writers() { + fn test_rwlock_writers_and_writers() { test_rwlock_exclusion(~RWlock(), Write, Write); test_rwlock_exclusion(~RWlock(), Write, Downgrade); test_rwlock_exclusion(~RWlock(), Downgrade, Write); test_rwlock_exclusion(~RWlock(), Downgrade, Downgrade); } #[cfg(test)] - pub fn test_rwlock_handshake(x: ~RWlock, + fn test_rwlock_handshake(x: ~RWlock, mode1: RWlockMode, mode2: RWlockMode, make_mode2_go_first: bool) { @@ -1178,7 +1178,7 @@ pub fn test_rwlock_handshake(x: ~RWlock, } } #[test] - pub fn test_rwlock_readers_and_readers() { + fn test_rwlock_readers_and_readers() { test_rwlock_handshake(~RWlock(), Read, Read, false); // The downgrader needs to get in before the reader gets in, otherwise // they cannot end up reading at the same time. @@ -1187,7 +1187,7 @@ pub fn test_rwlock_readers_and_readers() { // Two downgrade_reads can never both end up reading at the same time. } #[test] - pub fn test_rwlock_downgrade_unlock() { + fn test_rwlock_downgrade_unlock() { // Tests that downgrade can unlock the lock in both modes let x = ~RWlock(); do lock_rwlock_in_mode(x, Downgrade) { } @@ -1197,12 +1197,12 @@ pub fn test_rwlock_downgrade_unlock() { test_rwlock_exclusion(y, Write, Write); } #[test] - pub fn test_rwlock_read_recursive() { + fn test_rwlock_read_recursive() { let x = ~RWlock(); do x.read { do x.read { } } } #[test] - pub fn test_rwlock_cond_wait() { + fn test_rwlock_cond_wait() { // As test_mutex_cond_wait above. let x = ~RWlock(); @@ -1237,7 +1237,7 @@ pub fn test_rwlock_cond_wait() { do x.read { } // Just for good measure } #[cfg(test)] - pub fn test_rwlock_cond_broadcast_helper(num_waiters: uint, + fn test_rwlock_cond_broadcast_helper(num_waiters: uint, dg1: bool, dg2: bool) { // Much like the mutex broadcast test. Downgrade-enabled. @@ -1276,7 +1276,7 @@ fn lock_cond(x: &RWlock, downgrade: bool, blk: &fn(c: &Condvar)) { for ports.each |port| { let _ = port.recv(); } } #[test] - pub fn test_rwlock_cond_broadcast() { + fn test_rwlock_cond_broadcast() { test_rwlock_cond_broadcast_helper(0, true, true); test_rwlock_cond_broadcast_helper(0, true, false); test_rwlock_cond_broadcast_helper(0, false, true); @@ -1287,7 +1287,7 @@ pub fn test_rwlock_cond_broadcast() { test_rwlock_cond_broadcast_helper(12, false, false); } #[cfg(test)] #[ignore(cfg(windows))] - pub fn rwlock_kill_helper(mode1: RWlockMode, mode2: RWlockMode) { + fn rwlock_kill_helper(mode1: RWlockMode, mode2: RWlockMode) { // Mutex must get automatically unlocked if failed/killed within. let x = ~RWlock(); let x2 = (*x).clone(); @@ -1302,23 +1302,23 @@ pub fn rwlock_kill_helper(mode1: RWlockMode, mode2: RWlockMode) { do lock_rwlock_in_mode(x, mode2) { } } #[test] #[ignore(cfg(windows))] - pub fn test_rwlock_reader_killed_writer() { + fn test_rwlock_reader_killed_writer() { rwlock_kill_helper(Read, Write); } #[test] #[ignore(cfg(windows))] - pub fn test_rwlock_writer_killed_reader() { + fn test_rwlock_writer_killed_reader() { rwlock_kill_helper(Write,Read ); } #[test] #[ignore(cfg(windows))] - pub fn test_rwlock_reader_killed_reader() { + fn test_rwlock_reader_killed_reader() { rwlock_kill_helper(Read, Read ); } #[test] #[ignore(cfg(windows))] - pub fn test_rwlock_writer_killed_writer() { + fn test_rwlock_writer_killed_writer() { rwlock_kill_helper(Write,Write); } #[test] #[ignore(cfg(windows))] - pub fn test_rwlock_kill_downgrader() { + fn test_rwlock_kill_downgrader() { rwlock_kill_helper(Downgrade, Read); rwlock_kill_helper(Read, Downgrade); rwlock_kill_helper(Downgrade, Write); @@ -1333,7 +1333,7 @@ pub fn test_rwlock_kill_downgrader() { rwlock_kill_helper(Downgrade, DowngradeRead); } #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn test_rwlock_downgrade_cant_swap() { + fn test_rwlock_downgrade_cant_swap() { // Tests that you can't downgrade with a different rwlock's token. let x = ~RWlock(); let y = ~RWlock(); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 04fa319b2553..ee83a0c9bd65 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -823,7 +823,7 @@ fn f() { } #[test] #[ignore(cfg(windows))] - pub fn test_should_fail() { + fn test_should_fail() { fn f() { fail!(); } let desc = TestDescAndFn { desc: TestDesc { @@ -841,7 +841,7 @@ pub fn test_should_fail() { } #[test] - pub fn test_should_fail_but_succeeds() { + fn test_should_fail_but_succeeds() { fn f() { } let desc = TestDescAndFn { desc: TestDesc { @@ -859,7 +859,7 @@ fn f() { } } #[test] - pub fn first_free_arg_should_be_a_filter() { + fn first_free_arg_should_be_a_filter() { let args = ~[~"progname", ~"filter"]; let opts = match parse_opts(args) { either::Left(copy o) => o, @@ -869,7 +869,7 @@ pub fn first_free_arg_should_be_a_filter() { } #[test] - pub fn parse_ignored_flag() { + fn parse_ignored_flag() { let args = ~[~"progname", ~"filter", ~"--ignored"]; let opts = match parse_opts(args) { either::Left(copy o) => o, diff --git a/src/libstd/time.rs b/src/libstd/time.rs index adfa12594aac..70dc4d8cfebb 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -872,7 +872,7 @@ mod tests { use core::str; use core::vec; - pub fn test_get_time() { + fn test_get_time() { static some_recent_date: i64 = 1325376000i64; // 2012-01-01T00:00:00Z static some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z @@ -893,7 +893,7 @@ pub fn test_get_time() { } } - pub fn test_precise_time() { + fn test_precise_time() { let s0 = precise_time_s(); let ns1 = precise_time_ns(); @@ -910,7 +910,7 @@ pub fn test_precise_time() { assert!(ns2 >= ns1); } - pub fn test_at_utc() { + fn test_at_utc() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -931,7 +931,7 @@ pub fn test_at_utc() { assert!(utc.tm_nsec == 54321_i32); } - pub fn test_at() { + fn test_at() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -959,7 +959,7 @@ pub fn test_at() { assert!(local.tm_nsec == 54321_i32); } - pub fn test_to_timespec() { + fn test_to_timespec() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -970,7 +970,7 @@ pub fn test_to_timespec() { assert!(utc.to_local().to_timespec() == time); } - pub fn test_conversions() { + fn test_conversions() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -986,7 +986,7 @@ pub fn test_conversions() { assert!(utc.to_local().to_utc() == utc); } - pub fn test_strptime() { + fn test_strptime() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -1144,7 +1144,7 @@ fn test(s: &str, format: &str) -> bool { assert!(test(~"%", ~"%%")); } - pub fn test_ctime() { + fn test_ctime() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -1158,7 +1158,7 @@ pub fn test_ctime() { assert!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); } - pub fn test_strftime() { + fn test_strftime() { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); @@ -1231,7 +1231,7 @@ pub fn test_strftime() { assert!(utc.rfc3339() == ~"2009-02-13T23:31:30Z"); } - pub fn test_timespec_eq_ord() { + fn test_timespec_eq_ord() { use core::cmp::{eq, ge, gt, le, lt, ne}; let a = &Timespec::new(-2, 1); @@ -1265,7 +1265,7 @@ pub fn test_timespec_eq_ord() { } #[test] - pub fn run_tests() { + fn run_tests() { // The tests race on tzset. So instead of having many independent // tests, we will just call the functions now. test_get_time(); diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 99e772b0c95a..c229e72ae5d4 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -183,13 +183,13 @@ mod test { use core::pipes::{stream, SharedChan}; #[test] - pub fn test_gl_timer_simple_sleep_test() { + fn test_gl_timer_simple_sleep_test() { let hl_loop = &uv::global_loop::get(); sleep(hl_loop, 1u); } #[test] - pub fn test_gl_timer_sleep_stress1() { + fn test_gl_timer_sleep_stress1() { let hl_loop = &uv::global_loop::get(); for iter::repeat(50u) { sleep(hl_loop, 1u); @@ -197,7 +197,7 @@ pub fn test_gl_timer_sleep_stress1() { } #[test] - pub fn test_gl_timer_sleep_stress2() { + fn test_gl_timer_sleep_stress2() { let (po, ch) = stream(); let ch = SharedChan(ch); let hl_loop = &uv::global_loop::get(); @@ -241,7 +241,7 @@ pub fn test_gl_timer_sleep_stress2() { #[test] #[cfg(ignore)] - pub fn test_gl_timer_recv_timeout_before_time_passes() { + fn test_gl_timer_recv_timeout_before_time_passes() { let times = 100; let mut successes = 0; let mut failures = 0; @@ -270,7 +270,7 @@ pub fn test_gl_timer_recv_timeout_before_time_passes() { } #[test] - pub fn test_gl_timer_recv_timeout_after_time_passes() { + fn test_gl_timer_recv_timeout_after_time_passes() { let times = 100; let mut successes = 0; let mut failures = 0; diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 3bf297027d4d..740ecec001f8 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -1225,7 +1225,7 @@ pub unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 { } #[cfg(test)] -pub mod test { +mod test { use core::prelude::*; use core::comm::{SharedChan, stream, GenericChan, GenericPort}; use super::*; @@ -1759,11 +1759,11 @@ pub fn impl_uv_tcp_server_and_request() { #[cfg(target_os="darwin")] #[cfg(target_os="linux")] #[cfg(target_os="android")] - pub mod tcp_and_server_client_test { + mod tcp_and_server_client_test { #[cfg(target_arch="x86_64")] - pub mod impl64 { + mod impl64 { #[test] - pub fn test_uv_ll_tcp_server_and_request() { + fn test_uv_ll_tcp_server_and_request() { unsafe { super::super::impl_uv_tcp_server_and_request(); } @@ -1772,10 +1772,10 @@ pub fn test_uv_ll_tcp_server_and_request() { #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] #[cfg(target_arch="mips")] - pub mod impl32 { + mod impl32 { #[test] #[ignore(cfg(target_os = "linux"))] - pub fn test_uv_ll_tcp_server_and_request() { + fn test_uv_ll_tcp_server_and_request() { unsafe { super::super::impl_uv_tcp_server_and_request(); } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 59e4dddc73be..bc930515a5d8 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -781,7 +781,7 @@ fn consume_whitespace(rdr: @mut StringReader) { } #[cfg(test)] -pub mod test { +mod test { use super::*; use ast; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index cf29f170f406..88ecabe28f52 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2248,7 +2248,7 @@ pub fn print_onceness(s: @ps, o: ast::Onceness) { } #[cfg(test)] -pub mod test { +mod test { use super::*; use ast; diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 4108871d0089..1133fd850d84 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -66,43 +66,47 @@ fn get(&self, idx: uint) -> T { self.vect[idx] } fn len(&self) -> uint { let vect = &*self.vect; vect.len() } } -#[test] -#[should_fail] -pub fn i1 () { - let i : Interner<@~str> = Interner::new(); - i.get(13); -} +#[cfg(test)] +mod tests { + use super::*; + #[test] + #[should_fail] + fn i1 () { + let i : Interner<@~str> = Interner::new(); + i.get(13); + } -#[test] -pub fn i2 () { - let i : Interner<@~str> = Interner::new(); - // first one is zero: - assert_eq!(i.intern (@~"dog"), 0); - // re-use gets the same entry: - assert_eq!(i.intern (@~"dog"), 0); - // different string gets a different #: - assert_eq!(i.intern (@~"cat"), 1); - assert_eq!(i.intern (@~"cat"), 1); - // dog is still at zero - assert_eq!(i.intern (@~"dog"), 0); - // gensym gets 3 - assert_eq!(i.gensym (@~"zebra" ), 2); - // gensym of same string gets new number : - assert_eq!(i.gensym (@~"zebra" ), 3); - // gensym of *existing* string gets new number: - assert_eq!(i.gensym (@~"dog"), 4); - assert_eq!(i.get(0), @~"dog"); - assert_eq!(i.get(1), @~"cat"); - assert_eq!(i.get(2), @~"zebra"); - assert_eq!(i.get(3), @~"zebra"); - assert_eq!(i.get(4), @~"dog"); -} + #[test] + fn i2 () { + let i : Interner<@~str> = Interner::new(); + // first one is zero: + assert_eq!(i.intern (@~"dog"), 0); + // re-use gets the same entry: + assert_eq!(i.intern (@~"dog"), 0); + // different string gets a different #: + assert_eq!(i.intern (@~"cat"), 1); + assert_eq!(i.intern (@~"cat"), 1); + // dog is still at zero + assert_eq!(i.intern (@~"dog"), 0); + // gensym gets 3 + assert_eq!(i.gensym (@~"zebra" ), 2); + // gensym of same string gets new number : + assert_eq!(i.gensym (@~"zebra" ), 3); + // gensym of *existing* string gets new number: + assert_eq!(i.gensym (@~"dog"), 4); + assert_eq!(i.get(0), @~"dog"); + assert_eq!(i.get(1), @~"cat"); + assert_eq!(i.get(2), @~"zebra"); + assert_eq!(i.get(3), @~"zebra"); + assert_eq!(i.get(4), @~"dog"); + } -#[test] -pub fn i3 () { - let i : Interner<@~str> = Interner::prefill([@~"Alan",@~"Bob",@~"Carol"]); - assert_eq!(i.get(0), @~"Alan"); - assert_eq!(i.get(1), @~"Bob"); - assert_eq!(i.get(2), @~"Carol"); - assert_eq!(i.intern(@~"Bob"), 1); -} + #[test] + fn i3 () { + let i : Interner<@~str> = Interner::prefill([@~"Alan",@~"Bob",@~"Carol"]); + assert_eq!(i.get(0), @~"Alan"); + assert_eq!(i.get(1), @~"Bob"); + assert_eq!(i.get(2), @~"Carol"); + assert_eq!(i.intern(@~"Bob"), 1); + } +} \ No newline at end of file