libcore,std,syntax,rustc: move tests into mod tests
, make them private (no pub mod or pub fn).
This commit is contained in:
parent
f10cf26e25
commit
d3be98e9f5
37 changed files with 1254 additions and 1227 deletions
|
@ -277,11 +277,14 @@ pub mod raw {
|
|||
pub unsafe fn reserve_at_least<T>(v: &mut @[T], n: uint) {
|
||||
reserve(v, uint::next_power_of_two(n));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test() {
|
||||
#[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| {
|
||||
|
@ -294,28 +297,28 @@ pub fn test() {
|
|||
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]
|
||||
pub fn append_test() {
|
||||
#[test]
|
||||
fn append_test() {
|
||||
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_from_owned() {
|
||||
#[test]
|
||||
fn test_from_owned() {
|
||||
assert!(from_owned::<int>(~[]) == @[]);
|
||||
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() {
|
||||
#[test]
|
||||
fn test_from_slice() {
|
||||
assert!(from_slice::<int>([]) == @[]);
|
||||
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]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_transmute() {
|
||||
fn test_transmute() {
|
||||
use managed::raw::BoxRepr;
|
||||
unsafe {
|
||||
let x = @100u8;
|
||||
|
@ -146,7 +146,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_transmute2() {
|
||||
fn test_transmute2() {
|
||||
unsafe {
|
||||
assert!(~[76u8, 0u8] == transmute(~"L"));
|
||||
}
|
||||
|
|
|
@ -426,12 +426,12 @@ pub fn try_send_one<T: Owned>(chan: ChanOne<T>, 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 mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_oneshot() {
|
||||
fn test_oneshot() {
|
||||
let (c, p) = oneshot::init();
|
||||
|
||||
oneshot::client::send(c, ());
|
||||
|
|
|
@ -357,8 +357,13 @@ impl Streaming for SipState {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_siphash() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
|
||||
#[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, ],
|
||||
|
@ -462,37 +467,37 @@ pub fn test_siphash() {
|
|||
|
||||
t += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test] #[cfg(target_arch = "arm")]
|
||||
pub fn test_hash_uint() {
|
||||
#[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 = "x86_64")]
|
||||
pub fn test_hash_uint() {
|
||||
}
|
||||
#[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] #[cfg(target_arch = "x86")]
|
||||
pub fn test_hash_uint() {
|
||||
}
|
||||
#[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]
|
||||
pub fn test_hash_idempotent() {
|
||||
#[test]
|
||||
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() {
|
||||
#[test]
|
||||
fn test_hash_no_bytes_dropped_64() {
|
||||
let val = 0xdeadbeef_deadbeef_u64;
|
||||
|
||||
assert!(val.hash() != zero_byte(val, 0).hash());
|
||||
|
@ -508,10 +513,10 @@ pub fn test_hash_no_bytes_dropped_64() {
|
|||
assert!(byte < 8);
|
||||
val & !(0xff << (byte * 8))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_hash_no_bytes_dropped_32() {
|
||||
#[test]
|
||||
fn test_hash_no_bytes_dropped_32() {
|
||||
let val = 0xdeadbeef_u32;
|
||||
|
||||
assert!(val.hash() != zero_byte(val, 0).hash());
|
||||
|
@ -523,4 +528,5 @@ pub fn test_hash_no_bytes_dropped_32() {
|
|||
assert!(byte < 4);
|
||||
val & !(0xff << (byte * 8))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_find_or_insert() {
|
||||
fn test_find_or_insert() {
|
||||
let mut m = HashMap::new::<int, int>();
|
||||
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::<int, int>();
|
||||
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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_map {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_expand() {
|
||||
fn test_expand() {
|
||||
let mut m = HashMap::new();
|
||||
|
||||
assert!(m.len() == 0);
|
||||
|
|
|
@ -29,7 +29,6 @@ use from_str;
|
|||
|
||||
#[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;
|
||||
|
@ -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,8 +467,18 @@ impl ops::Neg<float> for float {
|
|||
fn neg(&self) -> float { -*self }
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_from_str() {
|
||||
#[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");
|
||||
}
|
||||
|
||||
#[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));
|
||||
|
@ -519,10 +522,10 @@ pub fn test_from_str() {
|
|||
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() {
|
||||
#[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));
|
||||
|
@ -571,10 +574,10 @@ pub fn test_from_str_hex() {
|
|||
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() {
|
||||
#[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");
|
||||
|
@ -590,22 +593,22 @@ pub fn test_to_str_hex() {
|
|||
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() {
|
||||
#[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() {
|
||||
#[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() {
|
||||
#[test]
|
||||
pub fn test_positive() {
|
||||
assert!((is_positive(infinity)));
|
||||
assert!((is_positive(1.)));
|
||||
assert!((is_positive(0.)));
|
||||
|
@ -613,10 +616,10 @@ pub fn test_positive() {
|
|||
assert!((!is_positive(neg_infinity)));
|
||||
assert!((!is_positive(1./neg_infinity)));
|
||||
assert!((!is_positive(NaN)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_negative() {
|
||||
#[test]
|
||||
pub fn test_negative() {
|
||||
assert!((!is_negative(infinity)));
|
||||
assert!((!is_negative(1.)));
|
||||
assert!((!is_negative(0.)));
|
||||
|
@ -624,10 +627,10 @@ pub fn test_negative() {
|
|||
assert!((is_negative(neg_infinity)));
|
||||
assert!((is_negative(1./neg_infinity)));
|
||||
assert!((!is_negative(NaN)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_nonpositive() {
|
||||
#[test]
|
||||
pub fn test_nonpositive() {
|
||||
assert!((!is_nonpositive(infinity)));
|
||||
assert!((!is_nonpositive(1.)));
|
||||
assert!((!is_nonpositive(0.)));
|
||||
|
@ -635,10 +638,10 @@ pub fn test_nonpositive() {
|
|||
assert!((is_nonpositive(neg_infinity)));
|
||||
assert!((is_nonpositive(1./neg_infinity)));
|
||||
assert!((!is_nonpositive(NaN)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_nonnegative() {
|
||||
#[test]
|
||||
pub fn test_nonnegative() {
|
||||
assert!((is_nonnegative(infinity)));
|
||||
assert!((is_nonnegative(1.)));
|
||||
assert!((is_nonnegative(0.)));
|
||||
|
@ -646,24 +649,24 @@ pub fn test_nonnegative() {
|
|||
assert!((!is_nonnegative(neg_infinity)));
|
||||
assert!((!is_nonnegative(1./neg_infinity)));
|
||||
assert!((!is_nonnegative(NaN)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_to_str_inf() {
|
||||
#[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() {
|
||||
#[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
|
||||
|
|
|
@ -277,8 +277,14 @@ impl ToStrRadix for T {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_str() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use super::inst::T;
|
||||
use prelude::*;
|
||||
|
||||
#[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));
|
||||
|
@ -293,10 +299,10 @@ fn test_from_str() {
|
|||
|
||||
assert!(from_str(~" ").is_none());
|
||||
assert!(from_str(~"x").is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_bytes() {
|
||||
#[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));
|
||||
|
@ -323,20 +329,20 @@ fn test_parse_bytes() {
|
|||
|
||||
assert!(parse_bytes(to_bytes(~"Z"), 35u).is_none());
|
||||
assert!(parse_bytes(to_bytes(~"-9"), 2u).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_to_str() {
|
||||
#[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() {
|
||||
#[test]
|
||||
fn test_int_to_str_overflow() {
|
||||
let mut i8_val: i8 = 127_i8;
|
||||
assert!((i8::to_str(i8_val) == ~"127"));
|
||||
|
||||
|
@ -360,10 +366,10 @@ fn test_int_to_str_overflow() {
|
|||
|
||||
i64_val += 1 as i64;
|
||||
assert!((i64::to_str(i64_val) == ~"-9223372036854775808"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_int_from_str_overflow() {
|
||||
#[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()));
|
||||
|
@ -395,10 +401,10 @@ fn test_int_from_str_overflow() {
|
|||
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() {
|
||||
#[test]
|
||||
fn test_ranges() {
|
||||
let mut l = ~[];
|
||||
|
||||
for range(0,3) |i| {
|
||||
|
@ -447,11 +453,12 @@ pub fn test_ranges() {
|
|||
for range_step(0,10,-1) |_i| {
|
||||
fail!(~"unreachable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_range_step_zero_step() {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_range_step_zero_step() {
|
||||
for range_step(0,10,0) |_i| {}
|
||||
}
|
||||
}
|
|
@ -242,8 +242,13 @@ impl ToStrRadix for T {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_to_str() {
|
||||
#[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");
|
||||
|
@ -251,10 +256,10 @@ pub fn test_to_str() {
|
|||
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() {
|
||||
#[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));
|
||||
|
@ -264,10 +269,10 @@ pub fn test_from_str() {
|
|||
assert!(from_str(~"").is_none());
|
||||
assert!(from_str(~" ").is_none());
|
||||
assert!(from_str(~"x").is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_parse_bytes() {
|
||||
#[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));
|
||||
|
@ -280,10 +285,10 @@ pub fn test_parse_bytes() {
|
|||
|
||||
assert!(parse_bytes(to_bytes(~"Z"), 10u).is_none());
|
||||
assert!(parse_bytes(to_bytes(~"_"), 2u).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_uint_to_str_overflow() {
|
||||
#[test]
|
||||
fn test_uint_to_str_overflow() {
|
||||
let mut u8_val: u8 = 255_u8;
|
||||
assert!((u8::to_str(u8_val) == ~"255"));
|
||||
|
||||
|
@ -307,10 +312,10 @@ fn test_uint_to_str_overflow() {
|
|||
|
||||
u64_val += 1 as u64;
|
||||
assert!((u64::to_str(u64_val) == ~"0"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_uint_from_str_overflow() {
|
||||
#[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()));
|
||||
|
@ -342,24 +347,24 @@ fn test_uint_from_str_overflow() {
|
|||
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() {
|
||||
#[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() {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
pub fn to_str_radix37() {
|
||||
uint::to_str_radix(100u, 37u);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_ranges() {
|
||||
#[test]
|
||||
pub fn test_ranges() {
|
||||
let mut l = ~[];
|
||||
|
||||
for range(0,3) |i| {
|
||||
|
@ -409,17 +414,18 @@ pub fn test_ranges() {
|
|||
for range_step(0,1,-10) |_i| {
|
||||
fail!(~"unreachable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_range_step_zero_step_up() {
|
||||
#[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() {
|
||||
}
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_range_step_zero_step_down() {
|
||||
for range_step(0,-10,0) |_i| {}
|
||||
}
|
||||
}
|
|
@ -957,13 +957,13 @@ pub mod rt {
|
|||
}
|
||||
|
||||
#[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 mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_oneshot() {
|
||||
fn test_oneshot() {
|
||||
let (c, p) = oneshot::init();
|
||||
|
||||
oneshot::client::send(c, ());
|
||||
|
|
|
@ -15,8 +15,6 @@ use libc;
|
|||
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,8 +339,13 @@ impl<'self,T:Ord> Ord for &'self const T {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test() {
|
||||
#[cfg(test)]
|
||||
pub mod ptr_tests {
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
unsafe {
|
||||
struct Pair {mut fst: int, mut snd: int};
|
||||
let mut p = Pair {fst: 10, snd: 20};
|
||||
|
@ -373,10 +376,10 @@ pub fn test() {
|
|||
assert!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
|
||||
v1[2] == 32000u16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_position() {
|
||||
#[test]
|
||||
fn test_position() {
|
||||
use str::as_c_str;
|
||||
use libc::c_char;
|
||||
|
||||
|
@ -389,10 +392,10 @@ pub fn test_position() {
|
|||
assert!(5u == as_c_str(s, |p| position(p,
|
||||
|c| *c == 0 as c_char)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_buf_len() {
|
||||
#[test]
|
||||
fn test_buf_len() {
|
||||
let s0 = ~"hello";
|
||||
let s1 = ~"there";
|
||||
let s2 = ~"thing";
|
||||
|
@ -407,10 +410,10 @@ pub fn test_buf_len() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_is_null() {
|
||||
#[test]
|
||||
fn test_is_null() {
|
||||
let p: *int = null();
|
||||
assert!(p.is_null());
|
||||
assert!(!p.is_not_null());
|
||||
|
@ -426,16 +429,11 @@ pub fn test_is_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_ptr_array_each_with_len() {
|
||||
unsafe {
|
||||
let one = ~"oneOne";
|
||||
let two = ~"twoTwo";
|
||||
|
@ -451,7 +449,7 @@ pub mod ptr_tests {
|
|||
let arr_ptr = &arr[0];
|
||||
let mut ctr = 0;
|
||||
let mut iteration_count = 0;
|
||||
ptr::array_each_with_len(arr_ptr, vec::len(arr),
|
||||
array_each_with_len(arr_ptr, vec::len(arr),
|
||||
|e| {
|
||||
let actual = str::raw::from_c_str(e);
|
||||
let expected = copy expected_arr[ctr];
|
||||
|
@ -466,7 +464,7 @@ pub mod ptr_tests {
|
|||
}
|
||||
}
|
||||
#[test]
|
||||
pub fn test_ptr_array_each() {
|
||||
fn test_ptr_array_each() {
|
||||
unsafe {
|
||||
let one = ~"oneOne";
|
||||
let two = ~"twoTwo";
|
||||
|
@ -484,7 +482,7 @@ pub mod ptr_tests {
|
|||
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!(
|
||||
|
@ -500,9 +498,9 @@ pub mod ptr_tests {
|
|||
#[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 mod ptr_tests {
|
|||
#[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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
#[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 mod tests {
|
|||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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<int> = r.choose_option([]);
|
||||
assert!(x.is_none());
|
||||
|
@ -860,7 +860,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn shuffle() {
|
||||
fn shuffle() {
|
||||
let r = rand::Rng();
|
||||
let empty: ~[int] = ~[];
|
||||
assert!(r.shuffle(~[]) == empty);
|
||||
|
@ -906,7 +906,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn random() {
|
||||
fn random() {
|
||||
// not sure how to test this aside from just getting a number
|
||||
let _n : uint = rand::random();
|
||||
}
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn waitpid() {
|
||||
fn waitpid() {
|
||||
let pid = run::spawn_process("false", [],
|
||||
&None, &None,
|
||||
0i32, 0i32, 0i32);
|
||||
|
@ -564,20 +564,20 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
|
||||
#[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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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::<u8>() == 1u);
|
||||
assert!(size_of::<u16>() == 2u);
|
||||
assert!(size_of::<u32>() == 4u);
|
||||
|
@ -176,20 +176,20 @@ pub mod tests {
|
|||
#[cfg(target_arch = "x86")]
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[cfg(target_arch = "mips")]
|
||||
pub fn size_of_32() {
|
||||
fn size_of_32() {
|
||||
assert!(size_of::<uint>() == 4u);
|
||||
assert!(size_of::<*uint>() == 4u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn size_of_64() {
|
||||
fn size_of_64() {
|
||||
assert!(size_of::<uint>() == 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::<Z>() == 0u);
|
||||
assert!(nonzero_size_of::<Z>() == 1u);
|
||||
|
@ -197,7 +197,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn align_of_basic() {
|
||||
fn align_of_basic() {
|
||||
assert!(pref_align_of::<u8>() == 1u);
|
||||
assert!(pref_align_of::<u16>() == 2u);
|
||||
assert!(pref_align_of::<u32>() == 4u);
|
||||
|
@ -207,20 +207,20 @@ pub mod tests {
|
|||
#[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::<uint>() == 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::<uint>() == 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;
|
||||
|
|
|
@ -925,7 +925,7 @@ fn test_spawn_sched_childs_on_default_sched() {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod testrt {
|
||||
mod testrt {
|
||||
use libc;
|
||||
|
||||
#[nolink]
|
||||
|
|
|
@ -286,14 +286,14 @@ pub impl<T:Owned> Exclusive<T> {
|
|||
}
|
||||
|
||||
#[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 mod tests {
|
|||
}
|
||||
|
||||
#[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);
|
||||
|
|
|
@ -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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
#[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 @@ mod test {
|
|||
|
||||
#[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 @@ mod test {
|
|||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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(),
|
||||
|
|
|
@ -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 mod 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,
|
||||
|
|
|
@ -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 mod test {
|
|||
})
|
||||
}
|
||||
|
||||
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 mod test {
|
|||
}
|
||||
|
||||
#[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));
|
||||
}
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
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.
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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"));
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_10_elements() {
|
||||
fn test_10_elements() {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
|
@ -954,7 +954,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_31_elements() {
|
||||
fn test_31_elements() {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_32_elements() {
|
||||
fn test_32_elements() {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_33_elements() {
|
||||
fn test_33_elements() {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
|
@ -1178,21 +1178,21 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_bitv_remove() {
|
||||
fn test_bitv_remove() {
|
||||
let mut a = BitvSet::new();
|
||||
|
||||
assert!(a.insert(1));
|
||||
|
@ -1430,7 +1430,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 {
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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::<int>();
|
||||
a.append(b);
|
||||
|
@ -586,7 +586,7 @@ mod tests {
|
|||
a.assert_consistent(); assert!(a.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_append_to_empty() {
|
||||
fn test_dlist_append_to_empty() {
|
||||
let a = DList::<int>();
|
||||
let b = from_vec(~[4,5,6]);
|
||||
a.append(b);
|
||||
|
@ -599,7 +599,7 @@ mod tests {
|
|||
a.assert_consistent(); assert!(a.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_append_two_empty() {
|
||||
fn test_dlist_append_two_empty() {
|
||||
let a = DList::<int>();
|
||||
let b = DList::<int>();
|
||||
a.append(b);
|
||||
|
@ -611,19 +611,19 @@ mod tests {
|
|||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
#[should_fail]
|
||||
pub fn test_dlist_append_self() {
|
||||
fn test_dlist_append_self() {
|
||||
let a = DList::<int>();
|
||||
a.append(a);
|
||||
}
|
||||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
#[should_fail]
|
||||
pub fn test_dlist_prepend_self() {
|
||||
fn test_dlist_prepend_self() {
|
||||
let a = DList::<int>();
|
||||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
a.assert_consistent(); assert!(a.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_reverse_empty() {
|
||||
fn test_dlist_reverse_empty() {
|
||||
let a = DList::<int>();
|
||||
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 @@ mod tests {
|
|||
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::<int>();
|
||||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
assert!(l.pop_tail().is_none());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_push() {
|
||||
fn test_dlist_push() {
|
||||
let l = DList::<int>();
|
||||
l.push(1);
|
||||
assert_eq!(l.head(), 1);
|
||||
|
@ -736,7 +736,7 @@ mod tests {
|
|||
assert_eq!(l.len(), 3);
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_push_head() {
|
||||
fn test_dlist_push_head() {
|
||||
let l = DList::<int>();
|
||||
l.push_head(3);
|
||||
assert_eq!(l.head(), 3);
|
||||
|
@ -750,12 +750,12 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
assert_eq!(x, 3);
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_head() {
|
||||
fn test_dlist_remove_head() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
|
@ -780,7 +780,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_mid() {
|
||||
fn test_dlist_remove_mid() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
|
@ -795,7 +795,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_tail() {
|
||||
fn test_dlist_remove_tail() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
|
@ -810,7 +810,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_one_two() {
|
||||
fn test_dlist_remove_one_two() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
|
@ -826,7 +826,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_one_three() {
|
||||
fn test_dlist_remove_one_three() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
|
@ -841,7 +841,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_two_three() {
|
||||
fn test_dlist_remove_two_three() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
|
@ -856,7 +856,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_remove_all() {
|
||||
fn test_dlist_remove_all() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
|
@ -869,7 +869,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_insert_n_before() {
|
||||
fn test_dlist_insert_n_before() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
|
@ -885,7 +885,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_insert_n_after() {
|
||||
fn test_dlist_insert_n_after() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
|
@ -901,7 +901,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_insert_before_head() {
|
||||
fn test_dlist_insert_before_head() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
|
@ -916,7 +916,7 @@ mod tests {
|
|||
l.assert_consistent(); assert!(l.is_empty());
|
||||
}
|
||||
#[test]
|
||||
pub fn test_dlist_insert_after_tail() {
|
||||
fn test_dlist_insert_after_tail() {
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
|
@ -931,7 +931,7 @@ mod tests {
|
|||
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::<int>();
|
||||
let _one = l.push_n(1);
|
||||
let two = l.push_n(2);
|
||||
|
@ -939,7 +939,7 @@ mod tests {
|
|||
l.assert_consistent();
|
||||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
pub fn test_dlist_cyclic_list() {
|
||||
fn test_dlist_cyclic_list() {
|
||||
let l = DList::<int>();
|
||||
let one = l.push_n(1);
|
||||
let _two = l.push_n(2);
|
||||
|
@ -949,32 +949,32 @@ mod tests {
|
|||
l.assert_consistent();
|
||||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
pub fn test_dlist_headless() {
|
||||
fn test_dlist_headless() {
|
||||
DList::<int>().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::<int>();
|
||||
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::<int>();
|
||||
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::<int>();
|
||||
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::<int>();
|
||||
let one = new_dlist_node(1);
|
||||
let two = new_dlist_node(2);
|
||||
|
|
|
@ -172,7 +172,7 @@ pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> {
|
|||
|
||||
#[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 mod test {
|
|||
}
|
||||
|
||||
#[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 mod test {
|
|||
#[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 || {
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
|
||||
// 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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
|
||||
// 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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
|
||||
// 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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
|
||||
// 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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
|
||||
// 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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_groups_getopts() {
|
||||
fn test_groups_getopts() {
|
||||
let short = ~[
|
||||
reqopt(~"b"), reqopt(~"banana"),
|
||||
optopt(~"a"), optopt(~"apple"),
|
||||
|
@ -1318,7 +1318,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ Options:
|
|||
}
|
||||
|
||||
#[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
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ mod tests {
|
|||
use core::option;
|
||||
|
||||
#[test]
|
||||
pub fn test_is_empty() {
|
||||
fn test_is_empty() {
|
||||
let empty : @list::List<int> = from_vec(~[]);
|
||||
let full1 = from_vec(~[1]);
|
||||
let full2 = from_vec(~['r', 'u']);
|
||||
|
@ -171,7 +171,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_from_vec_empty() {
|
||||
fn test_from_vec_empty() {
|
||||
let empty : @list::List<int> = from_vec(~[]);
|
||||
assert!((empty == @list::Nil::<int>));
|
||||
}
|
||||
|
||||
#[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::<int>;
|
||||
|
@ -199,7 +199,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_foldl2() {
|
||||
fn test_foldl2() {
|
||||
fn sub(a: &int, b: &int) -> int {
|
||||
*a - *b
|
||||
}
|
||||
|
@ -208,14 +208,14 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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::<int>;
|
||||
|
@ -224,7 +224,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_has() {
|
||||
fn test_has() {
|
||||
let l = from_vec(~[5, 8, 6]);
|
||||
let empty = @list::Nil::<int>;
|
||||
assert!((list::has(l, 5)));
|
||||
|
@ -234,7 +234,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_len() {
|
||||
fn test_len() {
|
||||
let l = from_vec(~[0, 1, 2]);
|
||||
let empty = @list::Nil::<int>;
|
||||
assert!((list::len(l) == 3u));
|
||||
|
@ -242,7 +242,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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])));
|
||||
}
|
||||
|
|
|
@ -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 @@ pub mod test {
|
|||
#[cfg(target_arch="x86")]
|
||||
#[cfg(target_arch="arm")]
|
||||
#[cfg(target_arch="mips")]
|
||||
pub mod impl32 {
|
||||
mod impl32 {
|
||||
use net::tcp::test::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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
|
||||
/*
|
||||
|
|
|
@ -282,7 +282,7 @@ mod tests {
|
|||
use core::vec;
|
||||
|
||||
#[test]
|
||||
pub fn test() {
|
||||
fn test() {
|
||||
struct Test {
|
||||
input: ~str,
|
||||
output: ~[u8],
|
||||
|
|
|
@ -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::<int>(v1);
|
||||
quick_sort3::<int>(v1);
|
||||
let mut i = 0;
|
||||
|
@ -745,7 +745,7 @@ mod test_qsort3 {
|
|||
}
|
||||
|
||||
#[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::<int>(v1);
|
||||
fn leual(a: &int, b: &int) -> bool { *a <= *b }
|
||||
quick_sort::<int>(v1, leual);
|
||||
|
@ -790,7 +790,7 @@ mod test_qsort {
|
|||
}
|
||||
|
||||
#[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 @@ mod test_qsort {
|
|||
|
||||
// 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::<int>(v1);
|
||||
pub fn le(a: &int, b: &int) -> bool { *a <= *b }
|
||||
let f = le;
|
||||
|
@ -856,7 +856,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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
|
||||
{
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
* 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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[test]
|
||||
pub fn test_mutex_cond_wait() {
|
||||
fn test_mutex_cond_wait() {
|
||||
let m = ~Mutex();
|
||||
|
||||
// Child wakes up parent
|
||||
|
@ -886,7 +886,7 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[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 @@ mod tests {
|
|||
// 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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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();
|
||||
|
|
|
@ -823,7 +823,7 @@ mod tests {
|
|||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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,
|
||||
|
|
|
@ -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 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn test_precise_time() {
|
||||
fn test_precise_time() {
|
||||
let s0 = precise_time_s();
|
||||
let ns1 = precise_time_ns();
|
||||
|
||||
|
@ -910,7 +910,7 @@ mod tests {
|
|||
assert!(ns2 >= ns1);
|
||||
}
|
||||
|
||||
pub fn test_at_utc() {
|
||||
fn test_at_utc() {
|
||||
os::setenv(~"TZ", ~"America/Los_Angeles");
|
||||
tzset();
|
||||
|
||||
|
@ -931,7 +931,7 @@ mod tests {
|
|||
assert!(utc.tm_nsec == 54321_i32);
|
||||
}
|
||||
|
||||
pub fn test_at() {
|
||||
fn test_at() {
|
||||
os::setenv(~"TZ", ~"America/Los_Angeles");
|
||||
tzset();
|
||||
|
||||
|
@ -959,7 +959,7 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
assert!(test(~"%", ~"%%"));
|
||||
}
|
||||
|
||||
pub fn test_ctime() {
|
||||
fn test_ctime() {
|
||||
os::setenv(~"TZ", ~"America/Los_Angeles");
|
||||
tzset();
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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();
|
||||
|
|
|
@ -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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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 @@ mod test {
|
|||
|
||||
#[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 @@ mod test {
|
|||
}
|
||||
|
||||
#[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;
|
||||
|
|
|
@ -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 mod test {
|
|||
#[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 mod test {
|
|||
#[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();
|
||||
}
|
||||
|
|
|
@ -781,7 +781,7 @@ fn consume_whitespace(rdr: @mut StringReader) {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use ast;
|
||||
|
|
|
@ -2248,7 +2248,7 @@ pub fn print_onceness(s: @ps, o: ast::Onceness) {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use ast;
|
||||
|
|
|
@ -66,15 +66,18 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
|
|||
fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
pub fn i1 () {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn i1 () {
|
||||
let i : Interner<@~str> = Interner::new();
|
||||
i.get(13);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn i2 () {
|
||||
#[test]
|
||||
fn i2 () {
|
||||
let i : Interner<@~str> = Interner::new();
|
||||
// first one is zero:
|
||||
assert_eq!(i.intern (@~"dog"), 0);
|
||||
|
@ -96,13 +99,14 @@ pub fn i2 () {
|
|||
assert_eq!(i.get(2), @~"zebra");
|
||||
assert_eq!(i.get(3), @~"zebra");
|
||||
assert_eq!(i.get(4), @~"dog");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn i3 () {
|
||||
#[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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue