diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-03-29 17:48:44 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-03-29 17:48:44 -0700 |
| commit | 0de7635f534f0c02e211a2104afa7e0e15391e14 (patch) | |
| tree | 9945984e801d60e15e700456b694a18bf547fef8 /src/libstd | |
| parent | e5c7a9e3423c91c120cc4e69436dc7ee2dd1a1ab (diff) | |
| parent | f864934f548be9f03d2c0512de8d7e908469e2ae (diff) | |
| download | rust-0de7635f534f0c02e211a2104afa7e0e15391e14.tar.gz rust-0de7635f534f0c02e211a2104afa7e0e15391e14.zip | |
Merge remote-tracking branch 'remotes/origin/incoming' into serial
Diffstat (limited to 'src/libstd')
37 files changed, 1292 insertions, 1292 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 02c50cc7c98..ac8dd1a5d65 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -44,7 +44,7 @@ pub impl<'self> Condvar<'self> { */ #[inline(always)] fn wait_on(&self, condvar_id: uint) { - fail_unless!(!*self.failed); + assert!(!*self.failed); self.cond.wait_on(condvar_id); // This is why we need to wrap sync::condvar. check_poison(self.is_mutex, *self.failed); @@ -60,7 +60,7 @@ pub impl<'self> Condvar<'self> { */ #[inline(always)] fn signal_on(&self, condvar_id: uint) -> bool { - fail_unless!(!*self.failed); + assert!(!*self.failed); self.cond.signal_on(condvar_id) } @@ -74,7 +74,7 @@ pub impl<'self> Condvar<'self> { */ #[inline(always)] fn broadcast_on(&self, condvar_id: uint) -> uint { - fail_unless!(!*self.failed); + assert!(!*self.failed); self.cond.broadcast_on(condvar_id) } } @@ -230,7 +230,7 @@ struct PoisonOnFail { impl Drop for PoisonOnFail { fn finalize(&self) { unsafe { - /* fail_unless!(!*self.failed); + /* assert!(!*self.failed); -- might be false in case of cond.wait() */ if task::failing() { *self.failed = true; @@ -392,7 +392,7 @@ pub impl<T:Const + Owned> RWARC<T> { // of this cast is removing the mutability.) let new_data = unsafe { cast::transmute_immut(data) }; // Downgrade ensured the token belonged to us. Just a sanity check. - fail_unless!(ptr::ref_eq(&state.data, new_data)); + assert!(ptr::ref_eq(&state.data, new_data)); // Produce new token RWReadMode { data: new_data, @@ -505,13 +505,13 @@ mod tests { let arc_v = p.recv(); let v = *arc::get::<~[int]>(&arc_v); - fail_unless!(v[3] == 4); + assert!(v[3] == 4); }; let c = p.recv(); c.send(arc::clone(&arc_v)); - fail_unless!((*arc::get(&arc_v))[2] == 3); + assert!((*arc::get(&arc_v))[2] == 3); info!(arc_v); } @@ -532,7 +532,7 @@ mod tests { } do arc.access_cond |state, cond| { comm::send_one(c.take(), ()); - fail_unless!(!*state); + assert!(!*state); while !*state { cond.wait(); } @@ -549,7 +549,7 @@ mod tests { do arc2.access_cond |one, cond| { cond.signal(); // Parent should fail when it wakes up. - fail_unless!(*one == 0); + assert!(*one == 0); } } @@ -566,11 +566,11 @@ mod tests { let arc2 = ~arc.clone(); do task::try || { do arc2.access |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } }; do arc.access |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -579,11 +579,11 @@ mod tests { let arc2 = (*arc).clone(); do task::try || { do arc2.write |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } }; do arc.read |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -592,11 +592,11 @@ mod tests { let arc2 = (*arc).clone(); do task::try || { do arc2.write |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } }; do arc.write |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -606,12 +606,12 @@ mod tests { do task::try || { do arc2.write_downgrade |write_mode| { do (&write_mode).write |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } } }; do arc.write |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] #[ignore(cfg(windows))] @@ -620,11 +620,11 @@ mod tests { let arc2 = (*arc).clone(); do task::try || { do arc2.read |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } }; do arc.read |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] #[ignore(cfg(windows))] @@ -633,11 +633,11 @@ mod tests { let arc2 = (*arc).clone(); do task::try || { do arc2.read |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } }; do arc.write |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] #[ignore(cfg(windows))] @@ -648,12 +648,12 @@ mod tests { do arc2.write_downgrade |write_mode| { let read_mode = arc2.downgrade(write_mode); do (&read_mode).read |one| { - fail_unless!(*one == 2); + assert!(*one == 2); } } }; do arc.write |one| { - fail_unless!(*one == 1); + assert!(*one == 1); } } #[test] @@ -681,7 +681,7 @@ mod tests { do task::task().future_result(|+r| children.push(r)).spawn || { do arc3.read |num| { - fail_unless!(*num >= 0); + assert!(*num >= 0); } } } @@ -691,7 +691,7 @@ mod tests { // Wait for writer to finish p.recv(); - do arc.read |num| { fail_unless!(*num == 10); } + do arc.read |num| { assert!(*num == 10); } } #[test] pub fn test_rw_downgrade() { @@ -712,7 +712,7 @@ mod tests { do task::spawn || { rp1.recv(); // wait for downgrader to give go-ahead do arcn.read |state| { - fail_unless!(*state == 31337); + assert!(*state == 31337); rc2.send(()); } } @@ -724,7 +724,7 @@ mod tests { do task::spawn || { wp1.recv(); do arc2.write_cond |state, cond| { - fail_unless!(*state == 0); + assert!(*state == 0); *state = 42; cond.signal(); } @@ -732,7 +732,7 @@ mod tests { do arc2.write |state| { // This shouldn't happen until after the downgrade read // section, and all other readers, finish. - fail_unless!(*state == 31337); + assert!(*state == 31337); *state = 42; } wc2.send(()); @@ -745,7 +745,7 @@ mod tests { while *state == 0 { cond.wait(); } - fail_unless!(*state == 42); + assert!(*state == 42); *state = 31337; // send to other readers for vec::each(reader_convos) |x| { @@ -763,7 +763,7 @@ mod tests { } } wc1.send(()); // tell writer to try again - fail_unless!(*state == 31337); + assert!(*state == 31337); } } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index d3452712728..0266f2d8631 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -159,23 +159,23 @@ mod tests { #[test] pub fn test_to_base64() { - fail_unless!((~"").to_base64() == ~""); - fail_unless!((~"f").to_base64() == ~"Zg=="); - fail_unless!((~"fo").to_base64() == ~"Zm8="); - fail_unless!((~"foo").to_base64() == ~"Zm9v"); - fail_unless!((~"foob").to_base64() == ~"Zm9vYg=="); - fail_unless!((~"fooba").to_base64() == ~"Zm9vYmE="); - fail_unless!((~"foobar").to_base64() == ~"Zm9vYmFy"); + assert!((~"").to_base64() == ~""); + assert!((~"f").to_base64() == ~"Zg=="); + assert!((~"fo").to_base64() == ~"Zm8="); + assert!((~"foo").to_base64() == ~"Zm9v"); + assert!((~"foob").to_base64() == ~"Zm9vYg=="); + assert!((~"fooba").to_base64() == ~"Zm9vYmE="); + assert!((~"foobar").to_base64() == ~"Zm9vYmFy"); } #[test] pub fn test_from_base64() { - fail_unless!((~"").from_base64() == str::to_bytes(~"")); - fail_unless!((~"Zg==").from_base64() == str::to_bytes(~"f")); - fail_unless!((~"Zm8=").from_base64() == str::to_bytes(~"fo")); - fail_unless!((~"Zm9v").from_base64() == str::to_bytes(~"foo")); - fail_unless!((~"Zm9vYg==").from_base64() == str::to_bytes(~"foob")); - fail_unless!((~"Zm9vYmE=").from_base64() == str::to_bytes(~"fooba")); - fail_unless!((~"Zm9vYmFy").from_base64() == str::to_bytes(~"foobar")); + assert!((~"").from_base64() == str::to_bytes(~"")); + assert!((~"Zg==").from_base64() == str::to_bytes(~"f")); + assert!((~"Zm8=").from_base64() == str::to_bytes(~"fo")); + assert!((~"Zm9v").from_base64() == str::to_bytes(~"foo")); + assert!((~"Zm9vYg==").from_base64() == str::to_bytes(~"foob")); + assert!((~"Zm9vYmE=").from_base64() == str::to_bytes(~"fooba")); + assert!((~"Zm9vYmFy").from_base64() == str::to_bytes(~"foobar")); } } diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 9671112bec0..35b1a28a465 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -162,7 +162,7 @@ impl Sub<BigUint, BigUint> for BigUint { lo }; - fail_unless!(borrow == 0); // <=> fail_unless!((self >= other)); + assert!(borrow == 0); // <=> assert!((self >= other)); return BigUint::new(diff); } } @@ -351,7 +351,7 @@ pub impl BigUint { n <<= 1; shift += 1; } - fail_unless!(shift < BigDigit::bits); + assert!(shift < BigDigit::bits); let (d, m) = divmod_inner(self << shift, other << shift); return (d, m >> shift); @@ -390,7 +390,7 @@ pub impl BigUint { for an.each_reverse |elt| { let ai = BigDigit::to_uint(carry, *elt); let di = ai / (bn as uint); - fail_unless!(di < BigDigit::base); + assert!(di < BigDigit::base); carry = (ai % (bn as uint)) as BigDigit; d = ~[di as BigDigit] + d; } @@ -434,7 +434,7 @@ pub impl BigUint { } fn to_str_radix(&self, radix: uint) -> ~str { - fail_unless!(1 < radix && radix <= 16); + assert!(1 < radix && radix <= 16); let (base, max_len) = get_radix_base(radix); if base == BigDigit::base { return fill_concat(self.data, radix, max_len) @@ -510,7 +510,7 @@ pub impl BigUint { #[cfg(target_arch = "x86_64")] priv fn get_radix_base(radix: uint) -> (uint, uint) { - fail_unless!(1 < radix && radix <= 16); + assert!(1 < radix && radix <= 16); match radix { 2 => (4294967296, 32), 3 => (3486784401, 20), @@ -535,7 +535,7 @@ priv fn get_radix_base(radix: uint) -> (uint, uint) { #[cfg(target_arch = "x86")] #[cfg(target_arch = "mips")] priv fn get_radix_base(radix: uint) -> (uint, uint) { - fail_unless!(1 < radix && radix <= 16); + assert!(1 < radix && radix <= 16); match radix { 2 => (65536, 16), 3 => (59049, 10), @@ -784,7 +784,7 @@ pub impl BigInt { if ss < os { return -1; } if ss > os { return 1; } - fail_unless!(ss == os); + assert!(ss == os); match ss { Zero => 0, Plus => self.data.cmp(&other.data), @@ -871,7 +871,7 @@ mod biguint_tests { #[test] fn test_from_slice() { fn check(slice: &[BigDigit], data: &[BigDigit]) { - fail_unless!(data == BigUint::from_slice(slice).data); + assert!(data == BigUint::from_slice(slice).data); } check(~[1], ~[1]); check(~[0, 0, 0], ~[]); @@ -889,30 +889,30 @@ mod biguint_tests { for vec::slice(data, i, data.len()).eachi |j0, nj| { let j = j0 + i; if i == j { - fail_unless!(ni.cmp(nj) == 0); - fail_unless!(nj.cmp(ni) == 0); - fail_unless!(ni == nj); - fail_unless!(!(ni != nj)); - fail_unless!(ni <= nj); - fail_unless!(ni >= nj); - fail_unless!(!(ni < nj)); - fail_unless!(!(ni > nj)); + assert!(ni.cmp(nj) == 0); + assert!(nj.cmp(ni) == 0); + assert!(ni == nj); + assert!(!(ni != nj)); + assert!(ni <= nj); + assert!(ni >= nj); + assert!(!(ni < nj)); + assert!(!(ni > nj)); } else { - fail_unless!(ni.cmp(nj) < 0); - fail_unless!(nj.cmp(ni) > 0); + assert!(ni.cmp(nj) < 0); + assert!(nj.cmp(ni) > 0); - fail_unless!(!(ni == nj)); - fail_unless!(ni != nj); + assert!(!(ni == nj)); + assert!(ni != nj); - fail_unless!(ni <= nj); - fail_unless!(!(ni >= nj)); - fail_unless!(ni < nj); - fail_unless!(!(ni > nj)); + assert!(ni <= nj); + assert!(!(ni >= nj)); + assert!(ni < nj); + assert!(!(ni > nj)); - fail_unless!(!(nj <= ni)); - fail_unless!(nj >= ni); - fail_unless!(!(nj < ni)); - fail_unless!(nj > ni); + assert!(!(nj <= ni)); + assert!(nj >= ni); + assert!(!(nj < ni)); + assert!(nj > ni); } } } @@ -921,7 +921,7 @@ mod biguint_tests { #[test] fn test_shl() { fn check(v: ~[BigDigit], shift: uint, ans: ~[BigDigit]) { - fail_unless!(BigUint::new(v) << shift == BigUint::new(ans)); + assert!(BigUint::new(v) << shift == BigUint::new(ans)); } check(~[], 3, ~[]); @@ -966,7 +966,7 @@ mod biguint_tests { #[ignore(cfg(target_arch = "mips"))] fn test_shr() { fn check(v: ~[BigDigit], shift: uint, ans: ~[BigDigit]) { - fail_unless!(BigUint::new(v) >> shift == BigUint::new(ans)); + assert!(BigUint::new(v) >> shift == BigUint::new(ans)); } check(~[], 3, ~[]); @@ -1008,8 +1008,8 @@ mod biguint_tests { fn test_convert_int() { fn check(v: ~[BigDigit], i: int) { let b = BigUint::new(v); - fail_unless!(b == IntConvertible::from_int(i)); - fail_unless!(b.to_int() == i); + assert!(b == IntConvertible::from_int(i)); + assert!(b.to_int() == i); } check(~[], 0); @@ -1018,17 +1018,17 @@ mod biguint_tests { check(~[ 0, 1], ((uint::max_value >> BigDigit::bits) + 1) as int); check(~[-1, -1 >> 1], int::max_value); - fail_unless!(BigUint::new(~[0, -1]).to_int() == int::max_value); - fail_unless!(BigUint::new(~[0, 0, 1]).to_int() == int::max_value); - fail_unless!(BigUint::new(~[0, 0, -1]).to_int() == int::max_value); + assert!(BigUint::new(~[0, -1]).to_int() == int::max_value); + assert!(BigUint::new(~[0, 0, 1]).to_int() == int::max_value); + assert!(BigUint::new(~[0, 0, -1]).to_int() == int::max_value); } #[test] fn test_convert_uint() { fn check(v: ~[BigDigit], u: uint) { let b = BigUint::new(v); - fail_unless!(b == BigUint::from_uint(u)); - fail_unless!(b.to_uint() == u); + assert!(b == BigUint::from_uint(u)); + assert!(b.to_uint() == u); } check(~[], 0); @@ -1038,8 +1038,8 @@ mod biguint_tests { check(~[ 0, -1], uint::max_value << BigDigit::bits); check(~[-1, -1], uint::max_value); - fail_unless!(BigUint::new(~[0, 0, 1]).to_uint() == uint::max_value); - fail_unless!(BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value); + assert!(BigUint::new(~[0, 0, 1]).to_uint() == uint::max_value); + assert!(BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value); } static sum_triples: &'static [(&'static [BigDigit], @@ -1064,8 +1064,8 @@ mod biguint_tests { let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); - fail_unless!(a + b == c); - fail_unless!(b + a == c); + assert!(a + b == c); + assert!(b + a == c); } } @@ -1077,8 +1077,8 @@ mod biguint_tests { let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); - fail_unless!(c - a == b); - fail_unless!(c - b == a); + assert!(c - a == b); + assert!(c - b == a); } } @@ -1128,8 +1128,8 @@ mod biguint_tests { let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); - fail_unless!(a * b == c); - fail_unless!(b * a == c); + assert!(a * b == c); + assert!(b * a == c); } for divmod_quadruples.each |elm| { @@ -1139,8 +1139,8 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); let d = BigUint::from_slice(dVec); - fail_unless!(a == b * c + d); - fail_unless!(a == c * b + d); + assert!(a == b * c + d); + assert!(a == c * b + d); } } @@ -1153,10 +1153,10 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); if a.is_not_zero() { - fail_unless!(c.divmod(&a) == (b, Zero::zero())); + assert!(c.divmod(&a) == (b, Zero::zero())); } if b.is_not_zero() { - fail_unless!(c.divmod(&b) == (a, Zero::zero())); + assert!(c.divmod(&b) == (a, Zero::zero())); } } @@ -1167,7 +1167,7 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); let d = BigUint::from_slice(dVec); - if b.is_not_zero() { fail_unless!(a.divmod(&b) == (c, d)); } + if b.is_not_zero() { assert!(a.divmod(&b) == (c, d)); } } } @@ -1234,7 +1234,7 @@ mod biguint_tests { let &(n, rs) = num_pair; for rs.each |str_pair| { let &(radix, str) = str_pair; - fail_unless!(n.to_str_radix(radix) == str); + assert!(n.to_str_radix(radix) == str); } } } @@ -1245,13 +1245,13 @@ mod biguint_tests { let &(n, rs) = num_pair; for rs.each |str_pair| { let &(radix, str) = str_pair; - fail_unless!(Some(n) == BigUint::from_str_radix(str, radix)); + assert!(Some(n) == BigUint::from_str_radix(str, radix)); } } - fail_unless!(BigUint::from_str_radix(~"Z", 10) == None); - fail_unless!(BigUint::from_str_radix(~"_", 2) == None); - fail_unless!(BigUint::from_str_radix(~"-1", 10) == None); + assert!(BigUint::from_str_radix(~"Z", 10) == None); + assert!(BigUint::from_str_radix(~"_", 2) == None); + assert!(BigUint::from_str_radix(~"-1", 10) == None); } #[test] @@ -1269,7 +1269,7 @@ mod biguint_tests { let ans = match BigUint::from_str_radix(s, 10) { Some(x) => x, None => fail!() }; - fail_unless!(n == ans); + assert!(n == ans); } check(3, "6"); @@ -1291,7 +1291,7 @@ mod bigint_tests { fn check(inp_s: Sign, inp_n: uint, ans_s: Sign, ans_n: uint) { let inp = BigInt::from_biguint(inp_s, BigUint::from_uint(inp_n)); let ans = BigInt { sign: ans_s, data: BigUint::from_uint(ans_n)}; - fail_unless!(inp == ans); + assert!(inp == ans); } check(Plus, 1, Plus, 1); check(Plus, 0, Zero, 0); @@ -1311,30 +1311,30 @@ mod bigint_tests { for vec::slice(nums, i, nums.len()).eachi |j0, nj| { let j = i + j0; if i == j { - fail_unless!(ni.cmp(nj) == 0); - fail_unless!(nj.cmp(ni) == 0); - fail_unless!(ni == nj); - fail_unless!(!(ni != nj)); - fail_unless!(ni <= nj); - fail_unless!(ni >= nj); - fail_unless!(!(ni < nj)); - fail_unless!(!(ni > nj)); + assert!(ni.cmp(nj) == 0); + assert!(nj.cmp(ni) == 0); + assert!(ni == nj); + assert!(!(ni != nj)); + assert!(ni <= nj); + assert!(ni >= nj); + assert!(!(ni < nj)); + assert!(!(ni > nj)); } else { - fail_unless!(ni.cmp(nj) < 0); - fail_unless!(nj.cmp(ni) > 0); + assert!(ni.cmp(nj) < 0); + assert!(nj.cmp(ni) > 0); - fail_unless!(!(ni == nj)); - fail_unless!(ni != nj); + assert!(!(ni == nj)); + assert!(ni != nj); - fail_unless!(ni <= nj); - fail_unless!(!(ni >= nj)); - fail_unless!(ni < nj); - fail_unless!(!(ni > nj)); + assert!(ni <= nj); + assert!(!(ni >= nj)); + assert!(ni < nj); + assert!(!(ni > nj)); - fail_unless!(!(nj <= ni)); - fail_unless!(nj >= ni); - fail_unless!(!(nj < ni)); - fail_unless!(nj > ni); + assert!(!(nj <= ni)); + assert!(nj >= ni); + assert!(!(nj < ni)); + assert!(nj > ni); } } } @@ -1343,8 +1343,8 @@ mod bigint_tests { #[test] fn test_convert_int() { fn check(b: BigInt, i: int) { - fail_unless!(b == IntConvertible::from_int(i)); - fail_unless!(b.to_int() == i); + assert!(b == IntConvertible::from_int(i)); + assert!(b.to_int() == i); } check(Zero::zero(), 0); @@ -1353,20 +1353,20 @@ mod bigint_tests { Plus, BigUint::from_uint(int::max_value as uint) ), int::max_value); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Plus, BigUint::from_uint(int::max_value as uint + 1) ).to_int() == int::max_value); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Plus, BigUint::new(~[1, 2, 3]) ).to_int() == int::max_value); check(BigInt::from_biguint( Minus, BigUint::from_uint(-int::min_value as uint) ), int::min_value); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Minus, BigUint::from_uint(-int::min_value as uint + 1) ).to_int() == int::min_value); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Minus, BigUint::new(~[1, 2, 3]) ).to_int() == int::min_value); } @@ -1374,8 +1374,8 @@ mod bigint_tests { #[test] fn test_convert_uint() { fn check(b: BigInt, u: uint) { - fail_unless!(b == BigInt::from_uint(u)); - fail_unless!(b.to_uint() == u); + assert!(b == BigInt::from_uint(u)); + assert!(b.to_uint() == u); } check(Zero::zero(), 0); @@ -1384,14 +1384,14 @@ mod bigint_tests { check( BigInt::from_biguint(Plus, BigUint::from_uint(uint::max_value)), uint::max_value); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Plus, BigUint::new(~[1, 2, 3]) ).to_uint() == uint::max_value); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Minus, BigUint::from_uint(uint::max_value) ).to_uint() == 0); - fail_unless!(BigInt::from_biguint( + assert!(BigInt::from_biguint( Minus, BigUint::new(~[1, 2, 3]) ).to_uint() == 0); } @@ -1418,14 +1418,14 @@ mod bigint_tests { let b = BigInt::from_slice(Plus, bVec); let c = BigInt::from_slice(Plus, cVec); - fail_unless!(a + b == c); - fail_unless!(b + a == c); - fail_unless!(c + (-a) == b); - fail_unless!(c + (-b) == a); - fail_unless!(a + (-c) == (-b)); - fail_unless!(b + (-c) == (-a)); - fail_unless!((-a) + (-b) == (-c)); - fail_unless!(a + (-a) == Zero::zero()); + assert!(a + b == c); + assert!(b + a == c); + assert!(c + (-a) == b); + assert!(c + (-b) == a); + assert!(a + (-c) == (-b)); + assert!(b + (-c) == (-a)); + assert!((-a) + (-b) == (-c)); + assert!(a + (-a) == Zero::zero()); } } @@ -1437,14 +1437,14 @@ mod bigint_tests { let b = BigInt::from_slice(Plus, bVec); let c = BigInt::from_slice(Plus, cVec); - fail_unless!(c - a == b); - fail_unless!(c - b == a); - fail_unless!((-b) - a == (-c)); - fail_unless!((-a) - b == (-c)); - fail_unless!(b - (-a) == c); - fail_unless!(a - (-b) == c); - fail_unless!((-c) - (-a) == (-b)); - fail_unless!(a - a == Zero::zero()); + assert!(c - a == b); + assert!(c - b == a); + assert!((-b) - a == (-c)); + assert!((-a) - b == (-c)); + assert!(b - (-a) == c); + assert!(a - (-b) == c); + assert!((-c) - (-a) == (-b)); + assert!(a - a == Zero::zero()); } } @@ -1494,11 +1494,11 @@ mod bigint_tests { let b = BigInt::from_slice(Plus, bVec); let c = BigInt::from_slice(Plus, cVec); - fail_unless!(a * b == c); - fail_unless!(b * a == c); + assert!(a * b == c); + assert!(b * a == c); - fail_unless!((-a) * b == -c); - fail_unless!((-b) * a == -c); + assert!((-a) * b == -c); + assert!((-b) * a == -c); } for divmod_quadruples.each |elm| { @@ -1508,8 +1508,8 @@ mod bigint_tests { let c = BigInt::from_slice(Plus, cVec); let d = BigInt::from_slice(Plus, dVec); - fail_unless!(a == b * c + d); - fail_unless!(a == c * b + d); + assert!(a == b * c + d); + assert!(a == c * b + d); } } @@ -1518,12 +1518,12 @@ mod bigint_tests { fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) { let (d, m) = a.divmod(b); if m.is_not_zero() { - fail_unless!(m.sign == b.sign); + assert!(m.sign == b.sign); } - fail_unless!(m.abs() <= b.abs()); - fail_unless!(*a == b * d + m); - fail_unless!(d == *ans_d); - fail_unless!(m == *ans_m); + assert!(m.abs() <= b.abs()); + assert!(*a == b * d + m); + assert!(d == *ans_d); + assert!(m == *ans_m); } fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) { @@ -1569,12 +1569,12 @@ mod bigint_tests { fn check_sub(a: &BigInt, b: &BigInt, ans_q: &BigInt, ans_r: &BigInt) { let (q, r) = a.quotrem(b); if r.is_not_zero() { - fail_unless!(r.sign == a.sign); + assert!(r.sign == a.sign); } - fail_unless!(r.abs() <= b.abs()); - fail_unless!(*a == b * q + r); - fail_unless!(q == *ans_q); - fail_unless!(r == *ans_r); + assert!(r.abs() <= b.abs()); + assert!(*a == b * q + r); + assert!(q == *ans_q); + assert!(r == *ans_r); } fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) { @@ -1609,7 +1609,7 @@ mod bigint_tests { #[test] fn test_to_str_radix() { fn check(n: int, ans: &str) { - fail_unless!(ans == IntConvertible::from_int::<BigInt>( + assert!(ans == IntConvertible::from_int::<BigInt>( n).to_str_radix(10)); } check(10, "10"); @@ -1624,7 +1624,7 @@ mod bigint_tests { fn test_from_str_radix() { fn check(s: &str, ans: Option<int>) { let ans = ans.map(|&n| IntConvertible::from_int(n)); - fail_unless!(BigInt::from_str_radix(s, 10) == ans); + assert!(BigInt::from_str_radix(s, 10) == ans); } check("10", Some(10)); check("1", Some(1)); @@ -1637,11 +1637,11 @@ mod bigint_tests { #[test] fn test_neg() { - fail_unless!(-BigInt::new(Plus, ~[1, 1, 1]) == + assert!(-BigInt::new(Plus, ~[1, 1, 1]) == BigInt::new(Minus, ~[1, 1, 1])); - fail_unless!(-BigInt::new(Minus, ~[1, 1, 1]) == + assert!(-BigInt::new(Minus, ~[1, 1, 1]) == BigInt::new(Plus, ~[1, 1, 1])); - fail_unless!(-Zero::zero::<BigInt>() == Zero::zero::<BigInt>()); + assert!(-Zero::zero::<BigInt>() == Zero::zero::<BigInt>()); } } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 8bac0fed3c9..f69e2130e71 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -132,7 +132,7 @@ pub impl BigBitv { fn process(&mut self, b: &BigBitv, nbits: uint, op: &fn(uint, uint) -> uint) -> bool { let len = b.storage.len(); - fail_unless!((self.storage.len() == len)); + assert!((self.storage.len() == len)); let mut changed = false; for uint::range(0, len) |i| { let mask = big_mask(nbits, i); @@ -300,7 +300,7 @@ pub impl Bitv { /// Retrieve the value at index `i` #[inline(always)] fn get(&self, i: uint) -> bool { - fail_unless!((i < self.nbits)); + assert!((i < self.nbits)); match self.rep { Big(ref b) => b.get(i), Small(ref s) => s.get(i) @@ -314,7 +314,7 @@ pub impl Bitv { */ #[inline(always)] fn set(&mut self, i: uint, x: bool) { - fail_unless!((i < self.nbits)); + assert!((i < self.nbits)); match self.rep { Big(ref mut b) => b.set(i, x), Small(ref mut s) => s.set(i, x) @@ -484,7 +484,7 @@ pub impl Bitv { * the bitvector and vector must have the same length */ fn eq_vec(&self, v: ~[uint]) -> bool { - fail_unless!(self.nbits == v.len()); + assert!(self.nbits == v.len()); let mut i = 0; while i < self.nbits { let w0 = self.get(i); @@ -725,7 +725,7 @@ impl Set<uint> for BitvSet { let nbits = self.capacity(); if value >= nbits { let newsize = uint::max(value, nbits * 2) / uint::bits + 1; - fail_unless!(newsize > self.bitv.storage.len()); + assert!(newsize > self.bitv.storage.len()); self.bitv.storage.grow(newsize, &0); } self.size += 1; @@ -884,10 +884,10 @@ mod tests { #[test] pub fn test_to_str() { let zerolen = Bitv::new(0u, false); - fail_unless!(zerolen.to_str() == ~""); + assert!(zerolen.to_str() == ~""); let eightbits = Bitv::new(8u, false); - fail_unless!(eightbits.to_str() == ~"00000000"); + assert!(eightbits.to_str() == ~"00000000"); } #[test] @@ -896,16 +896,16 @@ mod tests { let mut exp; act = Bitv::new(0u, false); exp = vec::from_elem::<uint>(0u, 0u); - fail_unless!(act.eq_vec(exp)); + assert!(act.eq_vec(exp)); } #[test] pub fn test_1_element() { let mut act; act = Bitv::new(1u, false); - fail_unless!(act.eq_vec(~[0u])); + assert!(act.eq_vec(~[0u])); act = Bitv::new(1u, true); - fail_unless!(act.eq_vec(~[1u])); + assert!(act.eq_vec(~[1u])); } #[test] @@ -913,7 +913,7 @@ mod tests { let mut b = bitv::Bitv::new(2, false); b.set(0, true); b.set(1, false); - fail_unless!(b.to_str() == ~"10"); + assert!(b.to_str() == ~"10"); } #[test] @@ -922,11 +922,11 @@ mod tests { // all 0 act = Bitv::new(10u, false); - fail_unless!((act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]))); + assert!((act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]))); // all 1 act = Bitv::new(10u, true); - fail_unless!((act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]))); + assert!((act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]))); // mixed act = Bitv::new(10u, false); @@ -935,7 +935,7 @@ mod tests { act.set(2u, true); act.set(3u, true); act.set(4u, true); - fail_unless!((act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u]))); + assert!((act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u]))); // mixed act = Bitv::new(10u, false); @@ -944,7 +944,7 @@ mod tests { act.set(7u, true); act.set(8u, true); act.set(9u, true); - fail_unless!((act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u]))); + assert!((act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u]))); // mixed act = Bitv::new(10u, false); @@ -952,7 +952,7 @@ mod tests { act.set(3u, true); act.set(6u, true); act.set(9u, true); - fail_unless!((act.eq_vec(~[1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u]))); + assert!((act.eq_vec(~[1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u]))); } #[test] @@ -961,14 +961,14 @@ mod tests { // all 0 act = Bitv::new(31u, false); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); // all 1 act = Bitv::new(31u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -983,7 +983,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -998,7 +998,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1012,7 +1012,7 @@ mod tests { act.set(28u, true); act.set(29u, true); act.set(30u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1022,7 +1022,7 @@ mod tests { act.set(3u, true); act.set(17u, true); act.set(30u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u])); @@ -1034,14 +1034,14 @@ mod tests { // all 0 act = Bitv::new(32u, false); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); // all 1 act = Bitv::new(32u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1056,7 +1056,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1071,7 +1071,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1086,7 +1086,7 @@ mod tests { act.set(29u, true); act.set(30u, true); act.set(31u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1097,7 +1097,7 @@ mod tests { act.set(17u, true); act.set(30u, true); act.set(31u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u])); @@ -1109,14 +1109,14 @@ mod tests { // all 0 act = Bitv::new(33u, false); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); // all 1 act = Bitv::new(33u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1131,7 +1131,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1146,7 +1146,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1161,7 +1161,7 @@ mod tests { act.set(29u, true); act.set(30u, true); act.set(31u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u])); @@ -1173,7 +1173,7 @@ mod tests { act.set(30u, true); act.set(31u, true); act.set(32u, true); - fail_unless!(act.eq_vec( + assert!(act.eq_vec( ~[0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u])); @@ -1183,14 +1183,14 @@ mod tests { pub fn test_equal_differing_sizes() { let v0 = Bitv::new(10u, false); let v1 = Bitv::new(11u, false); - fail_unless!(!v0.equal(&v1)); + assert!(!v0.equal(&v1)); } #[test] pub fn test_equal_greatly_differing_sizes() { let v0 = Bitv::new(10u, false); let v1 = Bitv::new(110u, false); - fail_unless!(!v0.equal(&v1)); + assert!(!v0.equal(&v1)); } #[test] @@ -1201,7 +1201,7 @@ mod tests { let mut b = bitv::Bitv::new(1, true); b.set(0, true); - fail_unless!(a.equal(&b)); + assert!(a.equal(&b)); } #[test] @@ -1216,38 +1216,38 @@ mod tests { b.set(i, true); } - fail_unless!(a.equal(&b)); + assert!(a.equal(&b)); } #[test] pub fn test_from_bytes() { let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); let str = ~"10110110" + ~"00000000" + ~"11111111"; - fail_unless!(bitv.to_str() == str); + assert!(bitv.to_str() == str); } #[test] pub fn test_to_bytes() { let mut bv = Bitv::new(3, true); bv.set(1, false); - fail_unless!(bv.to_bytes() == ~[0b10100000]); + assert!(bv.to_bytes() == ~[0b10100000]); let mut bv = Bitv::new(9, false); bv.set(2, true); bv.set(8, true); - fail_unless!(bv.to_bytes() == ~[0b00100000, 0b10000000]); + assert!(bv.to_bytes() == ~[0b00100000, 0b10000000]); } #[test] pub fn test_from_bools() { - fail_unless!(from_bools([true, false, true, true]).to_str() == + assert!(from_bools([true, false, true, true]).to_str() == ~"1011"); } #[test] pub fn test_to_bools() { let bools = ~[false, false, true, false, false, true, true, false]; - fail_unless!(from_bytes([0b00100110]).to_bools() == bools); + assert!(from_bytes([0b00100110]).to_bools() == bools); } #[test] @@ -1258,10 +1258,10 @@ mod tests { b1.set(1, true); b2.set(1, true); b2.set(2, true); - fail_unless!(b1.difference(&b2)); - fail_unless!(b1[0]); - fail_unless!(!b1[1]); - fail_unless!(!b1[2]); + assert!(b1.difference(&b2)); + assert!(b1[0]); + assert!(!b1[1]); + assert!(!b1[2]); } #[test] @@ -1272,10 +1272,10 @@ mod tests { b1.set(40, true); b2.set(40, true); b2.set(80, true); - fail_unless!(b1.difference(&b2)); - fail_unless!(b1[0]); - fail_unless!(!b1[40]); - fail_unless!(!b1[80]); + assert!(b1.difference(&b2)); + assert!(b1[0]); + assert!(!b1[40]); + assert!(!b1[80]); } #[test] @@ -1299,13 +1299,13 @@ mod tests { #[test] pub fn test_bitv_set_basic() { let mut b = BitvSet::new(); - fail_unless!(b.insert(3)); - fail_unless!(!b.insert(3)); - fail_unless!(b.contains(&3)); - fail_unless!(b.insert(400)); - fail_unless!(!b.insert(400)); - fail_unless!(b.contains(&400)); - fail_unless!(b.len() == 2); + assert!(b.insert(3)); + assert!(!b.insert(3)); + assert!(b.contains(&3)); + assert!(b.insert(400)); + assert!(!b.insert(400)); + assert!(b.contains(&400)); + assert!(b.len() == 2); } #[test] @@ -1313,26 +1313,26 @@ mod tests { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - fail_unless!(a.insert(11)); - fail_unless!(a.insert(1)); - fail_unless!(a.insert(3)); - fail_unless!(a.insert(77)); - fail_unless!(a.insert(103)); - fail_unless!(a.insert(5)); + assert!(a.insert(11)); + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(77)); + assert!(a.insert(103)); + assert!(a.insert(5)); - fail_unless!(b.insert(2)); - fail_unless!(b.insert(11)); - fail_unless!(b.insert(77)); - fail_unless!(b.insert(5)); - fail_unless!(b.insert(3)); + assert!(b.insert(2)); + assert!(b.insert(11)); + assert!(b.insert(77)); + assert!(b.insert(5)); + assert!(b.insert(3)); let mut i = 0; let expected = [3, 5, 11, 77]; for a.intersection(&b) |x| { - fail_unless!(*x == expected[i]); + assert!(*x == expected[i]); i += 1 } - fail_unless!(i == expected.len()); + assert!(i == expected.len()); } #[test] @@ -1340,22 +1340,22 @@ mod tests { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - fail_unless!(a.insert(1)); - fail_unless!(a.insert(3)); - fail_unless!(a.insert(5)); - fail_unless!(a.insert(200)); - fail_unless!(a.insert(500)); + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(200)); + assert!(a.insert(500)); - fail_unless!(b.insert(3)); - fail_unless!(b.insert(200)); + assert!(b.insert(3)); + assert!(b.insert(200)); let mut i = 0; let expected = [1, 5, 500]; for a.difference(&b) |x| { - fail_unless!(*x == expected[i]); + assert!(*x == expected[i]); i += 1 } - fail_unless!(i == expected.len()); + assert!(i == expected.len()); } #[test] @@ -1363,67 +1363,67 @@ mod tests { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - fail_unless!(a.insert(1)); - fail_unless!(a.insert(3)); - fail_unless!(a.insert(5)); - fail_unless!(a.insert(9)); - fail_unless!(a.insert(11)); + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); - fail_unless!(b.insert(3)); - fail_unless!(b.insert(9)); - fail_unless!(b.insert(14)); - fail_unless!(b.insert(220)); + assert!(b.insert(3)); + assert!(b.insert(9)); + assert!(b.insert(14)); + assert!(b.insert(220)); let mut i = 0; let expected = [1, 5, 11, 14, 220]; for a.symmetric_difference(&b) |x| { - fail_unless!(*x == expected[i]); + assert!(*x == expected[i]); i += 1 } - fail_unless!(i == expected.len()); + assert!(i == expected.len()); } #[test] pub fn test_bitv_set_union() { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - fail_unless!(a.insert(1)); - fail_unless!(a.insert(3)); - fail_unless!(a.insert(5)); - fail_unless!(a.insert(9)); - fail_unless!(a.insert(11)); - fail_unless!(a.insert(160)); - fail_unless!(a.insert(19)); - fail_unless!(a.insert(24)); - - fail_unless!(b.insert(1)); - fail_unless!(b.insert(5)); - fail_unless!(b.insert(9)); - fail_unless!(b.insert(13)); - fail_unless!(b.insert(19)); + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + assert!(a.insert(160)); + assert!(a.insert(19)); + assert!(a.insert(24)); + + assert!(b.insert(1)); + assert!(b.insert(5)); + assert!(b.insert(9)); + assert!(b.insert(13)); + assert!(b.insert(19)); let mut i = 0; let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160]; for a.union(&b) |x| { - fail_unless!(*x == expected[i]); + assert!(*x == expected[i]); i += 1 } - fail_unless!(i == expected.len()); + assert!(i == expected.len()); } #[test] pub fn test_bitv_remove() { let mut a = BitvSet::new(); - fail_unless!(a.insert(1)); - fail_unless!(a.remove(&1)); + assert!(a.insert(1)); + assert!(a.remove(&1)); - fail_unless!(a.insert(100)); - fail_unless!(a.remove(&100)); + assert!(a.insert(100)); + assert!(a.remove(&100)); - fail_unless!(a.insert(1000)); - fail_unless!(a.remove(&1000)); - fail_unless!(a.capacity() == uint::bits); + assert!(a.insert(1000)); + assert!(a.remove(&1000)); + assert!(a.capacity() == uint::bits); } fn rng() -> @rand::Rng { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 1787be75e24..113c8130349 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -122,7 +122,7 @@ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn()) * Fails if `ofs` is greater or equal to the length of the vector */ pub fn get<T:Copy>(t: CVec<T>, ofs: uint) -> T { - fail_unless!(ofs < len(t)); + assert!(ofs < len(t)); return unsafe { *ptr::mut_offset(t.base, ofs) }; } @@ -132,7 +132,7 @@ pub fn get<T:Copy>(t: CVec<T>, ofs: uint) -> T { * Fails if `ofs` is greater or equal to the length of the vector */ pub fn set<T:Copy>(t: CVec<T>, ofs: uint, v: T) { - fail_unless!(ofs < len(t)); + assert!(ofs < len(t)); unsafe { *ptr::mut_offset(t.base, ofs) = v }; } @@ -159,7 +159,7 @@ mod tests { unsafe { let mem = libc::malloc(n); - fail_unless!(mem as int != 0); + assert!(mem as int != 0); return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, || unsafe { free(mem) }) }; @@ -172,9 +172,9 @@ mod tests { set(cv, 3u, 8u8); set(cv, 4u, 9u8); - fail_unless!(get(cv, 3u) == 8u8); - fail_unless!(get(cv, 4u) == 9u8); - fail_unless!(len(cv) == 16u); + assert!(get(cv, 3u) == 8u8); + assert!(get(cv, 4u) == 9u8); + assert!(len(cv) == 16u); } #[test] @@ -202,7 +202,7 @@ mod tests { set(cv, 0u, 32u8); set(cv, 1u, 33u8); - fail_unless!(unsafe { *p } == 32u8); + assert!(unsafe { *p } == 32u8); set(cv, 2u, 34u8); /* safety */ } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 93a2f4e2acc..5d7f64a7c8f 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -53,15 +53,15 @@ impl FuzzyEq<f64> for f64 { #[test] fn test_fuzzy_equals() { - fail_unless!((&1.0f).fuzzy_eq(&1.0)); - fail_unless!((&1.0f32).fuzzy_eq(&1.0f32)); - fail_unless!((&1.0f64).fuzzy_eq(&1.0f64)); + assert!((&1.0f).fuzzy_eq(&1.0)); + assert!((&1.0f32).fuzzy_eq(&1.0f32)); + assert!((&1.0f64).fuzzy_eq(&1.0f64)); } #[test] fn test_fuzzy_eq_eps() { - fail_unless!((&1.2f).fuzzy_eq_eps(&0.9, &0.5)); - fail_unless!(!(&1.5f).fuzzy_eq_eps(&0.9, &0.5)); + assert!((&1.2f).fuzzy_eq_eps(&0.9, &0.5)); + assert!(!(&1.5f).fuzzy_eq_eps(&0.9, &0.5)); } #[test] @@ -87,16 +87,16 @@ mod test_complex{ let a = Complex {r: 0.9, i: 0.9}; let b = Complex {r: 0.9, i: 0.9}; - fail_unless!((a.fuzzy_eq(&b))); + assert!((a.fuzzy_eq(&b))); } #[test] fn test_fuzzy_eq_eps() { let other = Complex {r: 0.9, i: 0.9}; - fail_unless!((&Complex {r: 0.9, i: 1.2}).fuzzy_eq_eps(&other, &0.5)); - fail_unless!((&Complex {r: 1.2, i: 0.9}).fuzzy_eq_eps(&other, &0.5)); - fail_unless!(!(&Complex {r: 0.9, i: 1.5}).fuzzy_eq_eps(&other, &0.5)); - fail_unless!(!(&Complex {r: 1.5, i: 0.9}).fuzzy_eq_eps(&other, &0.5)); + assert!((&Complex {r: 0.9, i: 1.2}).fuzzy_eq_eps(&other, &0.5)); + assert!((&Complex {r: 1.2, i: 0.9}).fuzzy_eq_eps(&other, &0.5)); + assert!(!(&Complex {r: 0.9, i: 1.5}).fuzzy_eq_eps(&other, &0.5)); + assert!(!(&Complex {r: 1.5, i: 0.9}).fuzzy_eq_eps(&other, &0.5)); } } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 9f68c676222..0e0347406ae 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -105,7 +105,7 @@ mod test { left.send(~"abc"); right.send(123); - fail_unless!(left.recv() == 123); - fail_unless!(right.recv() == ~"abc"); + assert!(left.recv() == 123); + assert!(right.recv() == ~"abc"); } } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 72b68f8fe3a..e029b882472 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -120,7 +120,7 @@ pub impl<T> Deque<T> { /// Grow is only called on full elts, so nelts is also len(elts), unlike /// elsewhere. fn grow<T>(nelts: uint, lo: uint, elts: &mut [Option<T>]) -> ~[Option<T>] { - fail_unless!(nelts == elts.len()); + assert!(nelts == elts.len()); let mut rv = ~[]; do rv.grow_fn(nelts + 1) |i| { @@ -145,46 +145,46 @@ mod tests { #[test] fn test_simple() { let mut d = Deque::new(); - fail_unless!(d.len() == 0u); + assert!(d.len() == 0u); d.add_front(17); d.add_front(42); d.add_back(137); - fail_unless!(d.len() == 3u); + assert!(d.len() == 3u); d.add_back(137); - fail_unless!(d.len() == 4u); + assert!(d.len() == 4u); debug!(d.peek_front()); - fail_unless!(*d.peek_front() == 42); + assert!(*d.peek_front() == 42); debug!(d.peek_back()); - fail_unless!(*d.peek_back() == 137); + assert!(*d.peek_back() == 137); let mut i: int = d.pop_front(); debug!(i); - fail_unless!(i == 42); + assert!(i == 42); i = d.pop_back(); debug!(i); - fail_unless!(i == 137); + assert!(i == 137); i = d.pop_back(); debug!(i); - fail_unless!(i == 137); + assert!(i == 137); i = d.pop_back(); debug!(i); - fail_unless!(i == 17); - fail_unless!(d.len() == 0u); + assert!(i == 17); + assert!(d.len() == 0u); d.add_back(3); - fail_unless!(d.len() == 1u); + assert!(d.len() == 1u); d.add_front(2); - fail_unless!(d.len() == 2u); + assert!(d.len() == 2u); d.add_back(4); - fail_unless!(d.len() == 3u); + assert!(d.len() == 3u); d.add_front(1); - fail_unless!(d.len() == 4u); + assert!(d.len() == 4u); debug!(d.get(0)); debug!(d.get(1)); debug!(d.get(2)); debug!(d.get(3)); - fail_unless!(*d.get(0) == 1); - fail_unless!(*d.get(1) == 2); - fail_unless!(*d.get(2) == 3); - fail_unless!(*d.get(3) == 4); + assert!(*d.get(0) == 1); + assert!(*d.get(1) == 2); + assert!(*d.get(2) == 3); + assert!(*d.get(3) == 4); } #[test] @@ -195,62 +195,62 @@ mod tests { let d: @int = @175; let mut deq = Deque::new(); - fail_unless!(deq.len() == 0); + assert!(deq.len() == 0); deq.add_front(a); deq.add_front(b); deq.add_back(c); - fail_unless!(deq.len() == 3); + assert!(deq.len() == 3); deq.add_back(d); - fail_unless!(deq.len() == 4); - fail_unless!(*deq.peek_front() == b); - fail_unless!(*deq.peek_back() == d); - fail_unless!(deq.pop_front() == b); - fail_unless!(deq.pop_back() == d); - fail_unless!(deq.pop_back() == c); - fail_unless!(deq.pop_back() == a); - fail_unless!(deq.len() == 0); + assert!(deq.len() == 4); + assert!(*deq.peek_front() == b); + assert!(*deq.peek_back() == d); + assert!(deq.pop_front() == b); + assert!(deq.pop_back() == d); + assert!(deq.pop_back() == c); + assert!(deq.pop_back() == a); + assert!(deq.len() == 0); deq.add_back(c); - fail_unless!(deq.len() == 1); + assert!(deq.len() == 1); deq.add_front(b); - fail_unless!(deq.len() == 2); + assert!(deq.len() == 2); deq.add_back(d); - fail_unless!(deq.len() == 3); + assert!(deq.len() == 3); deq.add_front(a); - fail_unless!(deq.len() == 4); - fail_unless!(*deq.get(0) == a); - fail_unless!(*deq.get(1) == b); - fail_unless!(*deq.get(2) == c); - fail_unless!(*deq.get(3) == d); + assert!(deq.len() == 4); + assert!(*deq.get(0) == a); + assert!(*deq.get(1) == b); + assert!(*deq.get(2) == c); + assert!(*deq.get(3) == d); } fn test_parameterized<T:Copy + Eq + Durable>(a: T, b: T, c: T, d: T) { let mut deq = Deque::new(); - fail_unless!(deq.len() == 0); + assert!(deq.len() == 0); deq.add_front(a); deq.add_front(b); deq.add_back(c); - fail_unless!(deq.len() == 3); + assert!(deq.len() == 3); deq.add_back(d); - fail_unless!(deq.len() == 4); - fail_unless!(*deq.peek_front() == b); - fail_unless!(*deq.peek_back() == d); - fail_unless!(deq.pop_front() == b); - fail_unless!(deq.pop_back() == d); - fail_unless!(deq.pop_back() == c); - fail_unless!(deq.pop_back() == a); - fail_unless!(deq.len() == 0); + assert!(deq.len() == 4); + assert!(*deq.peek_front() == b); + assert!(*deq.peek_back() == d); + assert!(deq.pop_front() == b); + assert!(deq.pop_back() == d); + assert!(deq.pop_back() == c); + assert!(deq.pop_back() == a); + assert!(deq.len() == 0); deq.add_back(c); - fail_unless!(deq.len() == 1); + assert!(deq.len() == 1); deq.add_front(b); - fail_unless!(deq.len() == 2); + assert!(deq.len() == 2); deq.add_back(d); - fail_unless!(deq.len() == 3); + assert!(deq.len() == 3); deq.add_front(a); - fail_unless!(deq.len() == 4); - fail_unless!(*deq.get(0) == a); - fail_unless!(*deq.get(1) == b); - fail_unless!(*deq.get(2) == c); - fail_unless!(*deq.get(3) == d); + assert!(deq.len() == 4); + assert!(*deq.get(0) == a); + assert!(*deq.get(1) == b); + assert!(*deq.get(2) == c); + assert!(*deq.get(3) == d); } #[deriving(Eq)] diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 646f2ce6a84..b117c8d9882 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -179,22 +179,22 @@ pub mod reader { pub fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) } pub fn doc_as_u8(d: Doc) -> u8 { - fail_unless!(d.end == d.start + 1u); + assert!(d.end == d.start + 1u); (*d.data)[d.start] } pub fn doc_as_u16(d: Doc) -> u16 { - fail_unless!(d.end == d.start + 2u); + assert!(d.end == d.start + 2u); io::u64_from_be_bytes(*d.data, d.start, 2u) as u16 } pub fn doc_as_u32(d: Doc) -> u32 { - fail_unless!(d.end == d.start + 4u); + assert!(d.end == d.start + 4u); io::u64_from_be_bytes(*d.data, d.start, 4u) as u32 } pub fn doc_as_u64(d: Doc) -> u64 { - fail_unless!(d.end == d.start + 8u); + assert!(d.end == d.start + 8u); io::u64_from_be_bytes(*d.data, d.start, 8u) } @@ -537,7 +537,7 @@ pub mod writer { priv impl Encoder { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) { - fail_unless!(v <= 0xFFFF_FFFF_u); + assert!(v <= 0xFFFF_FFFF_u); self.wr_tagged_u32(t as uint, v as u32); } @@ -679,7 +679,7 @@ mod tests { let deser = reader::Decoder(ebml_doc); let v1 = serialize::Decodable::decode(&deser); debug!("v1 == %?", v1); - fail_unless!(v == v1); + assert!(v == v1); } test_v(Some(22)); diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 52cd0f51b5a..56c67156d3d 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -358,8 +358,8 @@ pub mod flatteners { impl<T:Copy + Owned> Unflattener<T> for PodUnflattener<T> { fn unflatten(&self, buf: ~[u8]) -> T { - fail_unless!(size_of::<T>() != 0); - fail_unless!(size_of::<T>() == buf.len()); + assert!(size_of::<T>() != 0); + assert!(size_of::<T>() == buf.len()); let addr_of_init: &u8 = unsafe { &*vec::raw::to_ptr(buf) }; let addr_of_value: &T = unsafe { cast::transmute(addr_of_init) }; copy *addr_of_value @@ -368,7 +368,7 @@ pub mod flatteners { impl<T:Copy + Owned> Flattener<T> for PodFlattener<T> { fn flatten(&self, val: T) -> ~[u8] { - fail_unless!(size_of::<T>() != 0); + assert!(size_of::<T>() != 0); let val: *T = ptr::to_unsafe_ptr(&val); let byte_value = val as *u8; unsafe { vec::from_buf(byte_value, size_of::<T>()) } @@ -519,11 +519,11 @@ pub mod bytepipes { let mut left = count; let mut bytes = ~[]; while !self.reader.eof() && left > 0 { - fail_unless!(left <= count); - fail_unless!(left > 0); + assert!(left <= count); + assert!(left > 0); let new_bytes = self.reader.read_bytes(left); bytes.push_all(new_bytes); - fail_unless!(new_bytes.len() <= left); + assert!(new_bytes.len() <= left); left -= new_bytes.len(); } @@ -576,7 +576,7 @@ pub mod bytepipes { return Some(bytes); } else if vec::uniq_len(&const self.buf) > 0 { let mut bytes = ::core::util::replace(&mut self.buf, ~[]); - fail_unless!(count > bytes.len()); + assert!(count > bytes.len()); match self.try_recv(count - bytes.len()) { Some(rest) => { bytes.push_all(rest); @@ -587,7 +587,7 @@ pub mod bytepipes { } else if vec::uniq_len(&const self.buf) == 0 { match self.port.try_recv() { Some(buf) => { - fail_unless!(!buf.is_empty()); + assert!(!buf.is_empty()); self.buf = buf; return self.try_recv(count); } @@ -655,7 +655,7 @@ mod test { let port = serial::reader_port(reader); let res: int = port.recv(); - fail_unless!(res == 10i); + assert!(res == 10i); } #[test] @@ -669,7 +669,7 @@ mod test { } for int::range(0, 10) |i| { - fail_unless!(i == port.recv()) + assert!(i == port.recv()) } } @@ -684,7 +684,7 @@ mod test { } for int::range(0, 10) |i| { - fail_unless!(@i == port.recv()) + assert!(@i == port.recv()) } } @@ -701,7 +701,7 @@ mod test { let port = pod::reader_port(reader); let res: int = port.recv(); - fail_unless!(res == 10); + assert!(res == 10); } #[test] @@ -715,7 +715,7 @@ mod test { } for int::range(0, 10) |i| { - fail_unless!(i == port.recv()) + assert!(i == port.recv()) } } @@ -799,7 +799,7 @@ mod test { kill_ch.send(None) }; - fail_unless!(listen_res.is_ok()); + assert!(listen_res.is_ok()); } // Client task @@ -812,7 +812,7 @@ mod test { debug!("connecting"); let iotask = &uv::global_loop::get(); let connect_result = tcp::connect(copy addr, port, iotask); - fail_unless!(connect_result.is_ok()); + assert!(connect_result.is_ok()); let sock = result::unwrap(connect_result); let socket_buf: tcp::TcpSocketBuf = tcp::socket_buf(sock); @@ -833,7 +833,7 @@ mod test { debug!("accepting connection"); let accept_result = tcp::accept(conn); debug!("accepted"); - fail_unless!(accept_result.is_ok()); + assert!(accept_result.is_ok()); let sock = result::unwrap(accept_result); res_chan.send(()); @@ -845,7 +845,7 @@ mod test { for int::range(0, 10) |i| { let j = port.recv(); debug!("receieved %?", j); - fail_unless!(i == j); + assert!(i == j); } // The test is over! @@ -891,7 +891,7 @@ mod test { let bytes = ~[]; let port = loader(bytes); let res: Option<int> = port.try_recv(); - fail_unless!(res.is_none()); + assert!(res.is_none()); } #[test] @@ -908,7 +908,7 @@ mod test { let bytes = ~[0]; let port = loader(bytes); let res: Option<int> = port.try_recv(); - fail_unless!(res.is_none()); + assert!(res.is_none()); } #[test] @@ -926,7 +926,7 @@ mod test { let bytes = CONTINUE.to_vec() + ~[0]; let port = loader(bytes); let res: Option<int> = port.try_recv(); - fail_unless!(res.is_none()); + assert!(res.is_none()); } #[test] @@ -939,7 +939,7 @@ mod test { } fn test_try_recv_none4<P:BytePort>(+loader: PortLoader<P>) { - fail_unless!(do task::try || { + assert!(do task::try || { static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD]; // The control word is followed by a valid length, // then undeserializable garbage diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 8504b3e8ae5..a4887306d2a 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -155,7 +155,7 @@ pub mod test { #[test] pub fn test_from_value() { let f = from_value(~"snail"); - fail_unless!(f.get() == ~"snail"); + assert!(f.get() == ~"snail"); } #[test] @@ -163,31 +163,31 @@ pub mod test { let (ch, po) = oneshot::init(); send_one(ch, ~"whale"); let f = from_port(po); - fail_unless!(f.get() == ~"whale"); + assert!(f.get() == ~"whale"); } #[test] pub fn test_from_fn() { let f = from_fn(|| ~"brail"); - fail_unless!(f.get() == ~"brail"); + assert!(f.get() == ~"brail"); } #[test] pub fn test_interface_get() { let f = from_value(~"fail"); - fail_unless!(f.get() == ~"fail"); + assert!(f.get() == ~"fail"); } #[test] pub fn test_get_ref_method() { let f = from_value(22); - fail_unless!(*f.get_ref() == 22); + assert!(*f.get_ref() == 22); } #[test] pub fn test_spawn() { let f = spawn(|| ~"bale"); - fail_unless!(f.get() == ~"bale"); + assert!(f.get() == ~"bale"); } #[test] @@ -204,7 +204,7 @@ pub mod test { let f = do spawn { copy expected }; do task::spawn || { let actual = f.get(); - fail_unless!(actual == expected); + assert!(actual == expected); } } } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 4525dc0ae61..df37c48ebe8 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -484,7 +484,7 @@ pub mod groups { pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - fail_unless!(len == 1 || len == 0); + assert!(len == 1 || len == 0); return OptGroup { short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -497,7 +497,7 @@ pub mod groups { pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - fail_unless!(len == 1 || len == 0); + assert!(len == 1 || len == 0); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -510,7 +510,7 @@ pub mod groups { pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup { let len = short_name.len(); - fail_unless!(len == 1 || len == 0); + assert!(len == 1 || len == 0); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: ~"", @@ -523,7 +523,7 @@ pub mod groups { pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - fail_unless!(len == 1 || len == 0); + assert!(len == 1 || len == 0); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -539,7 +539,7 @@ pub mod groups { pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - fail_unless!(len == 1 || len == 0); + assert!(len == 1 || len == 0); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -666,11 +666,11 @@ mod tests { pub fn check_fail_type(f: Fail_, ft: FailType) { match f { - ArgumentMissing(_) => fail_unless!(ft == ArgumentMissing_), - UnrecognizedOption(_) => fail_unless!(ft == UnrecognizedOption_), - OptionMissing(_) => fail_unless!(ft == OptionMissing_), - OptionDuplicated(_) => fail_unless!(ft == OptionDuplicated_), - UnexpectedArgument(_) => fail_unless!(ft == UnexpectedArgument_) + ArgumentMissing(_) => assert!(ft == ArgumentMissing_), + UnrecognizedOption(_) => assert!(ft == UnrecognizedOption_), + OptionMissing(_) => assert!(ft == OptionMissing_), + OptionDuplicated(_) => assert!(ft == OptionDuplicated_), + UnexpectedArgument(_) => assert!(ft == UnexpectedArgument_) } } @@ -683,8 +683,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"test"))); - fail_unless!((opt_str(m, ~"test") == ~"20")); + assert!((opt_present(m, ~"test"))); + assert!((opt_str(m, ~"test") == ~"20")); } _ => { fail!(~"test_reqopt_long failed"); } } @@ -730,8 +730,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"t"))); - fail_unless!((opt_str(m, ~"t") == ~"20")); + assert!((opt_present(m, ~"t"))); + assert!((opt_str(m, ~"t") == ~"20")); } _ => fail!() } @@ -779,8 +779,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"test"))); - fail_unless!((opt_str(m, ~"test") == ~"20")); + assert!((opt_present(m, ~"test"))); + assert!((opt_str(m, ~"test") == ~"20")); } _ => fail!() } @@ -792,7 +792,7 @@ mod tests { let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(!opt_present(m, ~"test")), + Ok(ref m) => assert!(!opt_present(m, ~"test")), _ => fail!() } } @@ -826,8 +826,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"t"))); - fail_unless!((opt_str(m, ~"t") == ~"20")); + assert!((opt_present(m, ~"t"))); + assert!((opt_str(m, ~"t") == ~"20")); } _ => fail!() } @@ -839,7 +839,7 @@ mod tests { let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(!opt_present(m, ~"t")), + Ok(ref m) => assert!(!opt_present(m, ~"t")), _ => fail!() } } @@ -874,7 +874,7 @@ mod tests { let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(opt_present(m, ~"test")), + Ok(ref m) => assert!(opt_present(m, ~"test")), _ => fail!() } } @@ -885,7 +885,7 @@ mod tests { let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(!opt_present(m, ~"test")), + Ok(ref m) => assert!(!opt_present(m, ~"test")), _ => fail!() } } @@ -921,7 +921,7 @@ mod tests { let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(opt_present(m, ~"t")), + Ok(ref m) => assert!(opt_present(m, ~"t")), _ => fail!() } } @@ -932,7 +932,7 @@ mod tests { let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(!opt_present(m, ~"t")), + Ok(ref m) => assert!(!opt_present(m, ~"t")), _ => fail!() } } @@ -946,7 +946,7 @@ mod tests { Ok(ref m) => { // The next variable after the flag is just a free argument - fail_unless!((m.free[0] == ~"20")); + assert!((m.free[0] == ~"20")); } _ => fail!() } @@ -971,7 +971,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_count(m, ~"v") == 1)); + assert!((opt_count(m, ~"v") == 1)); } _ => fail!() } @@ -984,7 +984,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_count(m, ~"v") == 2)); + assert!((opt_count(m, ~"v") == 2)); } _ => fail!() } @@ -997,7 +997,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_count(m, ~"v") == 2)); + assert!((opt_count(m, ~"v") == 2)); } _ => fail!() } @@ -1010,7 +1010,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_count(m, ~"verbose") == 1)); + assert!((opt_count(m, ~"verbose") == 1)); } _ => fail!() } @@ -1023,7 +1023,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_count(m, ~"verbose") == 2)); + assert!((opt_count(m, ~"verbose") == 2)); } _ => fail!() } @@ -1037,8 +1037,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"test"))); - fail_unless!((opt_str(m, ~"test") == ~"20")); + assert!((opt_present(m, ~"test"))); + assert!((opt_str(m, ~"test") == ~"20")); } _ => fail!() } @@ -1050,7 +1050,7 @@ mod tests { let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(!opt_present(m, ~"test")), + Ok(ref m) => assert!(!opt_present(m, ~"test")), _ => fail!() } } @@ -1073,11 +1073,11 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"test"))); - fail_unless!((opt_str(m, ~"test") == ~"20")); + assert!((opt_present(m, ~"test"))); + assert!((opt_str(m, ~"test") == ~"20")); let pair = opt_strs(m, ~"test"); - fail_unless!((pair[0] == ~"20")); - fail_unless!((pair[1] == ~"30")); + assert!((pair[0] == ~"20")); + assert!((pair[1] == ~"30")); } _ => fail!() } @@ -1090,8 +1090,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"t"))); - fail_unless!((opt_str(m, ~"t") == ~"20")); + assert!((opt_present(m, ~"t"))); + assert!((opt_str(m, ~"t") == ~"20")); } _ => fail!() } @@ -1103,7 +1103,7 @@ mod tests { let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => fail_unless!(!opt_present(m, ~"t")), + Ok(ref m) => assert!(!opt_present(m, ~"t")), _ => fail!() } } @@ -1126,11 +1126,11 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((opt_present(m, ~"t"))); - fail_unless!((opt_str(m, ~"t") == ~"20")); + assert!((opt_present(m, ~"t"))); + assert!((opt_str(m, ~"t") == ~"20")); let pair = opt_strs(m, ~"t"); - fail_unless!((pair[0] == ~"20")); - fail_unless!((pair[1] == ~"30")); + assert!((pair[0] == ~"20")); + assert!((pair[1] == ~"30")); } _ => fail!() } @@ -1171,20 +1171,20 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - fail_unless!((m.free[0] == ~"prog")); - fail_unless!((m.free[1] == ~"free1")); - fail_unless!((opt_str(m, ~"s") == ~"20")); - fail_unless!((m.free[2] == ~"free2")); - fail_unless!((opt_present(m, ~"flag"))); - fail_unless!((opt_str(m, ~"long") == ~"30")); - fail_unless!((opt_present(m, ~"f"))); + assert!((m.free[0] == ~"prog")); + assert!((m.free[1] == ~"free1")); + assert!((opt_str(m, ~"s") == ~"20")); + assert!((m.free[2] == ~"free2")); + assert!((opt_present(m, ~"flag"))); + assert!((opt_str(m, ~"long") == ~"30")); + assert!((opt_present(m, ~"f"))); let pair = opt_strs(m, ~"m"); - fail_unless!((pair[0] == ~"40")); - fail_unless!((pair[1] == ~"50")); + assert!((pair[0] == ~"40")); + assert!((pair[1] == ~"50")); let pair = opt_strs(m, ~"n"); - fail_unless!((pair[0] == ~"-A B")); - fail_unless!((pair[1] == ~"-60 70")); - fail_unless!((!opt_present(m, ~"notpresent"))); + assert!((pair[0] == ~"-A B")); + assert!((pair[1] == ~"-60 70")); + assert!((!opt_present(m, ~"notpresent"))); } _ => fail!() } @@ -1198,18 +1198,18 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - fail_unless!(opts_present(matches, ~[~"e"])); - fail_unless!(opts_present(matches, ~[~"encrypt"])); - fail_unless!(opts_present(matches, ~[~"encrypt", ~"e"])); - fail_unless!(opts_present(matches, ~[~"e", ~"encrypt"])); - fail_unless!(!opts_present(matches, ~[~"f"])); - fail_unless!(!opts_present(matches, ~[~"thing"])); - fail_unless!(!opts_present(matches, ~[])); + assert!(opts_present(matches, ~[~"e"])); + assert!(opts_present(matches, ~[~"encrypt"])); + assert!(opts_present(matches, ~[~"encrypt", ~"e"])); + assert!(opts_present(matches, ~[~"e", ~"encrypt"])); + assert!(!opts_present(matches, ~[~"f"])); + assert!(!opts_present(matches, ~[~"thing"])); + assert!(!opts_present(matches, ~[])); - fail_unless!(opts_str(matches, ~[~"e"]) == ~"foo"); - fail_unless!(opts_str(matches, ~[~"encrypt"]) == ~"foo"); - fail_unless!(opts_str(matches, ~[~"e", ~"encrypt"]) == ~"foo"); - fail_unless!(opts_str(matches, ~[~"encrypt", ~"e"]) == ~"foo"); + assert!(opts_str(matches, ~[~"e"]) == ~"foo"); + assert!(opts_str(matches, ~[~"encrypt"]) == ~"foo"); + assert!(opts_str(matches, ~[~"e", ~"encrypt"]) == ~"foo"); + assert!(opts_str(matches, ~[~"encrypt", ~"e"]) == ~"foo"); } #[test] @@ -1220,17 +1220,17 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - fail_unless!(opts_present(matches, ~[~"L"])); - fail_unless!(opts_str(matches, ~[~"L"]) == ~"foo"); - fail_unless!(opts_present(matches, ~[~"M"])); - fail_unless!(opts_str(matches, ~[~"M"]) == ~"."); + assert!(opts_present(matches, ~[~"L"])); + assert!(opts_str(matches, ~[~"L"]) == ~"foo"); + assert!(opts_present(matches, ~[~"M"])); + assert!(opts_str(matches, ~[~"M"]) == ~"."); } #[test] pub fn test_groups_reqopt() { let opt = groups::reqopt(~"b", ~"banana", ~"some bananas", ~"VAL"); - fail_unless!(opt == OptGroup { short_name: ~"b", + assert!(opt == OptGroup { short_name: ~"b", long_name: ~"banana", hint: ~"VAL", desc: ~"some bananas", @@ -1241,7 +1241,7 @@ mod tests { #[test] pub fn test_groups_optopt() { let opt = groups::optopt(~"a", ~"apple", ~"some apples", ~"VAL"); - fail_unless!(opt == OptGroup { short_name: ~"a", + assert!(opt == OptGroup { short_name: ~"a", long_name: ~"apple", hint: ~"VAL", desc: ~"some apples", @@ -1252,7 +1252,7 @@ mod tests { #[test] pub fn test_groups_optflag() { let opt = groups::optflag(~"k", ~"kiwi", ~"some kiwis"); - fail_unless!(opt == OptGroup { short_name: ~"k", + assert!(opt == OptGroup { short_name: ~"k", long_name: ~"kiwi", hint: ~"", desc: ~"some kiwis", @@ -1264,7 +1264,7 @@ mod tests { pub fn test_groups_optflagopt() { let opt = groups::optflagopt(~"p", ~"pineapple", ~"some pineapples", ~"VAL"); - fail_unless!(opt == OptGroup { short_name: ~"p", + assert!(opt == OptGroup { short_name: ~"p", long_name: ~"pineapple", hint: ~"VAL", desc: ~"some pineapples", @@ -1276,7 +1276,7 @@ mod tests { pub fn test_groups_optmulti() { let opt = groups::optmulti(~"l", ~"lime", ~"some limes", ~"VAL"); - fail_unless!(opt == OptGroup { short_name: ~"l", + assert!(opt == OptGroup { short_name: ~"l", long_name: ~"lime", hint: ~"VAL", desc: ~"some limes", @@ -1290,7 +1290,7 @@ mod tests { let verbose = groups::reqopt(~"b", ~"banana", ~"some bananas", ~"VAL"); - fail_unless!(groups::long_to_short(&verbose) == short); + assert!(groups::long_to_short(&verbose) == short); } #[test] @@ -1315,7 +1315,7 @@ mod tests { ~"-p", ~"16", ~"l", ~"35"]; // FIXME #4681: sort options here? - fail_unless!(getopts(sample_args, short) + assert!(getopts(sample_args, short) == groups::getopts(sample_args, verbose)); } @@ -1347,7 +1347,7 @@ Options: debug!("expected: <<%s>>", expected); debug!("generated: <<%s>>", generated_usage); - fail_unless!(generated_usage == expected); + assert!(generated_usage == expected); } #[test] @@ -1376,7 +1376,7 @@ Options: debug!("expected: <<%s>>", expected); debug!("generated: <<%s>>", usage); - fail_unless!(usage == expected) + assert!(usage == expected) } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index b918f8505c8..63d461ed4d3 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -165,28 +165,28 @@ mod tests { let full1 = from_vec(~[1]); let full2 = from_vec(~['r', 'u']); - fail_unless!(is_empty(empty)); - fail_unless!(!is_empty(full1)); - fail_unless!(!is_empty(full2)); + assert!(is_empty(empty)); + assert!(!is_empty(full1)); + assert!(!is_empty(full2)); } #[test] pub fn test_from_vec() { let l = from_vec(~[0, 1, 2]); - fail_unless!((head(l) == 0)); + assert!((head(l) == 0)); let tail_l = tail(l); - fail_unless!((head(tail_l) == 1)); + assert!((head(tail_l) == 1)); let tail_tail_l = tail(tail_l); - fail_unless!((head(tail_tail_l) == 2)); + assert!((head(tail_tail_l) == 2)); } #[test] pub fn test_from_vec_empty() { let empty : @list::List<int> = from_vec(~[]); - fail_unless!((empty == @list::Nil::<int>)); + assert!((empty == @list::Nil::<int>)); } #[test] @@ -194,8 +194,8 @@ mod tests { 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>; - fail_unless!((list::foldl(0u, l, add) == 10u)); - fail_unless!((list::foldl(0u, empty, add) == 0u)); + assert!((list::foldl(0u, l, add) == 10u)); + assert!((list::foldl(0u, empty, add) == 0u)); } #[test] @@ -204,14 +204,14 @@ mod tests { *a - *b } let l = from_vec(~[1, 2, 3, 4]); - fail_unless!((list::foldl(0, l, sub) == -10)); + assert!((list::foldl(0, l, sub) == -10)); } #[test] pub fn test_find_success() { fn match_(i: &int) -> bool { return *i == 2; } let l = from_vec(~[0, 1, 2]); - fail_unless!((list::find(l, match_) == option::Some(2))); + assert!((list::find(l, match_) == option::Some(2))); } #[test] @@ -219,31 +219,31 @@ mod tests { fn match_(_i: &int) -> bool { return false; } let l = from_vec(~[0, 1, 2]); let empty = @list::Nil::<int>; - fail_unless!((list::find(l, match_) == option::None::<int>)); - fail_unless!((list::find(empty, match_) == option::None::<int>)); + assert!((list::find(l, match_) == option::None::<int>)); + assert!((list::find(empty, match_) == option::None::<int>)); } #[test] pub fn test_has() { let l = from_vec(~[5, 8, 6]); let empty = @list::Nil::<int>; - fail_unless!((list::has(l, 5))); - fail_unless!((!list::has(l, 7))); - fail_unless!((list::has(l, 8))); - fail_unless!((!list::has(empty, 5))); + assert!((list::has(l, 5))); + assert!((!list::has(l, 7))); + assert!((list::has(l, 8))); + assert!((!list::has(empty, 5))); } #[test] pub fn test_len() { let l = from_vec(~[0, 1, 2]); let empty = @list::Nil::<int>; - fail_unless!((list::len(l) == 3u)); - fail_unless!((list::len(empty) == 0u)); + assert!((list::len(l) == 3u)); + assert!((list::len(empty) == 0u)); } #[test] pub fn test_append() { - fail_unless!(from_vec(~[1,2,3,4]) + assert!(from_vec(~[1,2,3,4]) == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4]))); } } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index e20ac624278..8f35376a6f1 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -125,17 +125,17 @@ pub fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } #[test] fn test_md4() { - fail_unless!(md4_text(~"") == ~"31d6cfe0d16ae931b73c59d7e0c089c0"); - fail_unless!(md4_text(~"a") == ~"bde52cb31de33e46245e05fbdbd6fb24"); - fail_unless!(md4_text(~"abc") == ~"a448017aaf21d8525fc10ae87aa6729d"); - fail_unless!(md4_text(~"message digest") == + assert!(md4_text(~"") == ~"31d6cfe0d16ae931b73c59d7e0c089c0"); + assert!(md4_text(~"a") == ~"bde52cb31de33e46245e05fbdbd6fb24"); + assert!(md4_text(~"abc") == ~"a448017aaf21d8525fc10ae87aa6729d"); + assert!(md4_text(~"message digest") == ~"d9130a8164549fe818874806e1c7014b"); - fail_unless!(md4_text(~"abcdefghijklmnopqrstuvwxyz") == + assert!(md4_text(~"abcdefghijklmnopqrstuvwxyz") == ~"d79e1c308aa5bbcdeea8ed63df412da9"); - fail_unless!(md4_text( + assert!(md4_text( ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 0123456789") == ~"043f8582f241db351ce627e153e7f0e4"); - fail_unless!(md4_text(~"1234567890123456789012345678901234567890123456789\ + assert!(md4_text(~"1234567890123456789012345678901234567890123456789\ 0123456789012345678901234567890") == ~"e33b4ddc9c38f2199c3e7b164fcc0536"); } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 4fd06f43164..6403e0eb5c4 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -379,7 +379,7 @@ mod test { #[test] fn test_ip_ipv4_parse_and_format_ip() { let localhost_str = ~"127.0.0.1"; - fail_unless!(format_addr(&v4::parse_addr(localhost_str)) + assert!(format_addr(&v4::parse_addr(localhost_str)) == localhost_str) } #[test] @@ -388,14 +388,14 @@ mod test { let format_result = format_addr(&v6::parse_addr(localhost_str)); debug!("results: expected: '%s' actual: '%s'", localhost_str, format_result); - fail_unless!(format_result == localhost_str); + assert!(format_result == localhost_str); } #[test] fn test_ip_ipv4_bad_parse() { match v4::try_parse_addr(~"b4df00d") { result::Err(ref err_info) => { debug!("got error as expected %?", err_info); - fail_unless!(true); + assert!(true); } result::Ok(ref addr) => { fail!(fmt!("Expected failure, but got addr %?", addr)); @@ -408,7 +408,7 @@ mod test { match v6::try_parse_addr(~"::,~2234k;") { result::Err(ref err_info) => { debug!("got error as expected %?", err_info); - fail_unless!(true); + assert!(true); } result::Ok(ref addr) => { fail!(fmt!("Expected failure, but got addr %?", addr)); @@ -439,7 +439,7 @@ mod test { } // at least one result.. this is going to vary from system // to system, based on stuff like the contents of /etc/hosts - fail_unless!(!results.is_empty()); + assert!(!results.is_empty()); } #[test] #[ignore(reason = "valgrind says it's leaky")] @@ -447,6 +447,6 @@ mod test { let localhost_name = ~"sjkl234m,./sdf"; let iotask = &uv::global_loop::get(); let ga_result = get_addr(localhost_name, iotask); - fail_unless!(result::is_err(&ga_result)); + assert!(result::is_err(&ga_result)); } } diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 998b8640b68..8a51af8573f 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -876,7 +876,7 @@ impl io::Reader for TcpSocketBuf { let mut count: uint = 0; loop { - fail_unless!(count < len); + assert!(count < len); // If possible, copy up to `len` bytes from the internal // `data.buf` into `buf` @@ -897,7 +897,7 @@ impl io::Reader for TcpSocketBuf { } } - fail_unless!(count <= len); + assert!(count <= len); if count == len { break; } @@ -1589,15 +1589,15 @@ pub mod test { server_port, expected_req, hl_loop); - fail_unless!(actual_resp_result.is_ok()); + assert!(actual_resp_result.is_ok()); let actual_resp = actual_resp_result.get(); let actual_req = server_result_po.recv(); debug!("REQ: expected: '%s' actual: '%s'", expected_req, actual_req); debug!("RESP: expected: '%s' actual: '%s'", expected_resp, actual_resp); - fail_unless!(str::contains(actual_req, expected_req)); - fail_unless!(str::contains(actual_resp, expected_resp)); + assert!(str::contains(actual_req, expected_req)); + assert!(str::contains(actual_resp, expected_resp)); } pub fn impl_gl_tcp_ipv4_get_peer_addr() { let hl_loop = &uv::global_loop::get(); @@ -1630,9 +1630,9 @@ pub mod test { debug!("testing peer address"); // This is what we are actually testing! - fail_unless!(net::ip::format_addr(&sock.get_peer_addr()) == + assert!(net::ip::format_addr(&sock.get_peer_addr()) == ~"127.0.0.1"); - fail_unless!(net::ip::get_port(&sock.get_peer_addr()) == 8887); + assert!(net::ip::get_port(&sock.get_peer_addr()) == 8887); // Fulfill the protocol the test server expects let resp_bytes = str::to_bytes(~"ping"); @@ -1693,7 +1693,7 @@ pub mod test { hl_loop); match listen_err { AddressInUse => { - fail_unless!(true); + assert!(true); } _ => { fail!(~"expected address_in_use listen error,"+ @@ -1712,7 +1712,7 @@ pub mod test { hl_loop); match listen_err { AccessDenied => { - fail_unless!(true); + assert!(true); } _ => { fail!(~"expected address_in_use listen error,"+ @@ -1749,7 +1749,7 @@ pub mod test { let server_addr = ip::v4::parse_addr(server_ip); let conn_result = connect(server_addr, server_port, iotask); if result::is_err(&conn_result) { - fail_unless!(false); + assert!(false); } let sock_buf = @socket_buf(result::unwrap(conn_result)); buf_write(sock_buf, expected_req); @@ -1764,8 +1764,8 @@ pub mod test { expected_req, actual_req); debug!("RESP: expected: '%s' actual: '%s'", expected_resp, actual_resp); - fail_unless!(str::contains(actual_req, expected_req)); - fail_unless!(str::contains(actual_resp, expected_resp)); + assert!(str::contains(actual_req, expected_req)); + assert!(str::contains(actual_resp, expected_resp)); } pub fn impl_tcp_socket_impl_reader_handles_eof() { @@ -1796,7 +1796,7 @@ pub mod test { let server_addr = ip::v4::parse_addr(server_ip); let conn_result = connect(server_addr, server_port, hl_loop); if result::is_err(&conn_result) { - fail_unless!(false); + assert!(false); } let sock_buf = @socket_buf(result::unwrap(conn_result)); buf_write(sock_buf, expected_req); @@ -1804,7 +1804,7 @@ pub mod test { let buf_reader = sock_buf as @Reader; let actual_response = str::from_bytes(buf_reader.read_whole_stream()); debug!("Actual response: %s", actual_response); - fail_unless!(expected_resp == actual_response); + assert!(expected_resp == actual_response); } fn buf_write<W:io::Writer>(w: &W, val: &str) { diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 9caab11d643..d23784953ef 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -733,83 +733,83 @@ impl to_bytes::IterBytes for Url { #[test] fn test_split_char_first() { let (u,v) = split_char_first(~"hello, sweet world", ','); - fail_unless!(u == ~"hello"); - fail_unless!(v == ~" sweet world"); + assert!(u == ~"hello"); + assert!(v == ~" sweet world"); let (u,v) = split_char_first(~"hello sweet world", ','); - fail_unless!(u == ~"hello sweet world"); - fail_unless!(v == ~""); + assert!(u == ~"hello sweet world"); + assert!(v == ~""); } #[test] fn test_get_authority() { let (u, h, p, r) = get_authority( "//user:pass@rust-lang.org/something").unwrap(); - fail_unless!(u == Some(UserInfo::new(~"user", Some(~"pass")))); - fail_unless!(h == ~"rust-lang.org"); - fail_unless!(p.is_none()); - fail_unless!(r == ~"/something"); + assert!(u == Some(UserInfo::new(~"user", Some(~"pass")))); + assert!(h == ~"rust-lang.org"); + assert!(p.is_none()); + assert!(r == ~"/something"); let (u, h, p, r) = get_authority( "//rust-lang.org:8000?something").unwrap(); - fail_unless!(u.is_none()); - fail_unless!(h == ~"rust-lang.org"); - fail_unless!(p == Some(~"8000")); - fail_unless!(r == ~"?something"); + assert!(u.is_none()); + assert!(h == ~"rust-lang.org"); + assert!(p == Some(~"8000")); + assert!(r == ~"?something"); let (u, h, p, r) = get_authority( "//rust-lang.org#blah").unwrap(); - fail_unless!(u.is_none()); - fail_unless!(h == ~"rust-lang.org"); - fail_unless!(p.is_none()); - fail_unless!(r == ~"#blah"); + assert!(u.is_none()); + assert!(h == ~"rust-lang.org"); + assert!(p.is_none()); + assert!(r == ~"#blah"); // ipv6 tests let (_, h, _, _) = get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap(); - fail_unless!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + assert!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); let (_, h, p, _) = get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap(); - fail_unless!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); - fail_unless!(p == Some(~"8000")); + assert!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + assert!(p == Some(~"8000")); let (u, h, p, _) = get_authority( "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah" ).unwrap(); - fail_unless!(u == Some(UserInfo::new(~"us", Some(~"p")))); - fail_unless!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); - fail_unless!(p == Some(~"8000")); + assert!(u == Some(UserInfo::new(~"us", Some(~"p")))); + assert!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + assert!(p == Some(~"8000")); // invalid authorities; - fail_unless!(get_authority("//user:pass@rust-lang:something").is_err()); - fail_unless!(get_authority("//user@rust-lang:something:/path").is_err()); - fail_unless!(get_authority( + assert!(get_authority("//user:pass@rust-lang:something").is_err()); + assert!(get_authority("//user@rust-lang:something:/path").is_err()); + assert!(get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err()); - fail_unless!(get_authority( + assert!(get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err()); // these parse as empty, because they don't start with '//' let (_, h, _, _) = get_authority(~"user:pass@rust-lang").unwrap(); - fail_unless!(h == ~""); + assert!(h == ~""); let (_, h, _, _) = get_authority(~"rust-lang.org").unwrap(); - fail_unless!(h == ~""); + assert!(h == ~""); } #[test] fn test_get_path() { let (p, r) = get_path("/something+%20orother", true).unwrap(); - fail_unless!(p == ~"/something+ orother"); - fail_unless!(r == ~""); + assert!(p == ~"/something+ orother"); + assert!(r == ~""); let (p, r) = get_path("test@email.com#fragment", false).unwrap(); - fail_unless!(p == ~"test@email.com"); - fail_unless!(r == ~"#fragment"); + assert!(p == ~"test@email.com"); + assert!(r == ~"#fragment"); let (p, r) = get_path(~"/gen/:addr=?q=v", false).unwrap(); - fail_unless!(p == ~"/gen/:addr="); - fail_unless!(r == ~"?q=v"); + assert!(p == ~"/gen/:addr="); + assert!(r == ~"?q=v"); //failure cases - fail_unless!(get_path(~"something?q", true).is_err()); + assert!(get_path(~"something?q", true).is_err()); } #[cfg(test)] @@ -826,247 +826,247 @@ mod tests { let up = from_str(url); let u = up.unwrap(); - fail_unless!(u.scheme == ~"http"); + assert!(u.scheme == ~"http"); let userinfo = u.user.get_ref(); - fail_unless!(userinfo.user == ~"user"); - fail_unless!(userinfo.pass.get_ref() == &~"pass"); - fail_unless!(u.host == ~"rust-lang.org"); - fail_unless!(u.path == ~"/doc"); - fail_unless!(u.query == ~[(~"s", ~"v")]); - fail_unless!(u.fragment.get_ref() == &~"something"); + assert!(userinfo.user == ~"user"); + assert!(userinfo.pass.get_ref() == &~"pass"); + assert!(u.host == ~"rust-lang.org"); + assert!(u.path == ~"/doc"); + assert!(u.query == ~[(~"s", ~"v")]); + assert!(u.fragment.get_ref() == &~"something"); } #[test] pub fn test_url_parse_host_slash() { let urlstr = ~"http://0.42.42.42/"; let url = from_str(urlstr).unwrap(); - fail_unless!(url.host == ~"0.42.42.42"); - fail_unless!(url.path == ~"/"); + assert!(url.host == ~"0.42.42.42"); + assert!(url.path == ~"/"); } #[test] pub fn test_url_with_underscores() { let urlstr = ~"http://dotcom.com/file_name.html"; let url = from_str(urlstr).unwrap(); - fail_unless!(url.path == ~"/file_name.html"); + assert!(url.path == ~"/file_name.html"); } #[test] pub fn test_url_with_dashes() { let urlstr = ~"http://dotcom.com/file-name.html"; let url = from_str(urlstr).unwrap(); - fail_unless!(url.path == ~"/file-name.html"); + assert!(url.path == ~"/file-name.html"); } #[test] pub fn test_no_scheme() { - fail_unless!(get_scheme("noschemehere.html").is_err()); + assert!(get_scheme("noschemehere.html").is_err()); } #[test] pub fn test_invalid_scheme_errors() { - fail_unless!(from_str("99://something").is_err()); - fail_unless!(from_str("://something").is_err()); + assert!(from_str("99://something").is_err()); + assert!(from_str("://something").is_err()); } #[test] pub fn test_full_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?s=v#something"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_userless_url_parse_and_format() { let url = ~"http://rust-lang.org/doc?s=v#something"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_queryless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc#something"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub 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"; - fail_unless!(from_str(url).unwrap().to_str() == should_be); + assert!(from_str(url).unwrap().to_str() == should_be); } #[test] pub fn test_fragmentless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?q=v"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_minimal_url_parse_and_format() { let url = ~"http://rust-lang.org/doc"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_scheme_host_only_url_parse_and_format() { let url = ~"http://rust-lang.org"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_pathless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org?q=v#something"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_scheme_host_fragment_only_url_parse_and_format() { let url = ~"http://rust-lang.org#something"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub 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(); - fail_unless!(u.path == ~"/doc uments"); - fail_unless!(u.query == ~[(~"ba%d ", ~"#&+")]); + assert!(u.path == ~"/doc uments"); + assert!(u.query == ~[(~"ba%d ", ~"#&+")]); } #[test] pub fn test_url_without_authority() { let url = ~"mailto:test@email.com"; - fail_unless!(from_str(url).unwrap().to_str() == url); + assert!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_encode() { - fail_unless!(encode("") == ~""); - fail_unless!(encode("http://example.com") == ~"http://example.com"); - fail_unless!(encode("foo bar% baz") == ~"foo%20bar%25%20baz"); - fail_unless!(encode(" ") == ~"%20"); - fail_unless!(encode("!") == ~"!"); - fail_unless!(encode("\"") == ~"\""); - fail_unless!(encode("#") == ~"#"); - fail_unless!(encode("$") == ~"$"); - fail_unless!(encode("%") == ~"%25"); - fail_unless!(encode("&") == ~"&"); - fail_unless!(encode("'") == ~"%27"); - fail_unless!(encode("(") == ~"("); - fail_unless!(encode(")") == ~")"); - fail_unless!(encode("*") == ~"*"); - fail_unless!(encode("+") == ~"+"); - fail_unless!(encode(",") == ~","); - fail_unless!(encode("/") == ~"/"); - fail_unless!(encode(":") == ~":"); - fail_unless!(encode(";") == ~";"); - fail_unless!(encode("=") == ~"="); - fail_unless!(encode("?") == ~"?"); - fail_unless!(encode("@") == ~"@"); - fail_unless!(encode("[") == ~"["); - fail_unless!(encode("]") == ~"]"); + assert!(encode("") == ~""); + assert!(encode("http://example.com") == ~"http://example.com"); + assert!(encode("foo bar% baz") == ~"foo%20bar%25%20baz"); + assert!(encode(" ") == ~"%20"); + assert!(encode("!") == ~"!"); + assert!(encode("\"") == ~"\""); + assert!(encode("#") == ~"#"); + assert!(encode("$") == ~"$"); + assert!(encode("%") == ~"%25"); + assert!(encode("&") == ~"&"); + assert!(encode("'") == ~"%27"); + assert!(encode("(") == ~"("); + assert!(encode(")") == ~")"); + assert!(encode("*") == ~"*"); + assert!(encode("+") == ~"+"); + assert!(encode(",") == ~","); + assert!(encode("/") == ~"/"); + assert!(encode(":") == ~":"); + assert!(encode(";") == ~";"); + assert!(encode("=") == ~"="); + assert!(encode("?") == ~"?"); + assert!(encode("@") == ~"@"); + assert!(encode("[") == ~"["); + assert!(encode("]") == ~"]"); } #[test] pub fn test_encode_component() { - fail_unless!(encode_component("") == ~""); - fail_unless!(encode_component("http://example.com") == + assert!(encode_component("") == ~""); + assert!(encode_component("http://example.com") == ~"http%3A%2F%2Fexample.com"); - fail_unless!(encode_component("foo bar% baz") == + assert!(encode_component("foo bar% baz") == ~"foo%20bar%25%20baz"); - fail_unless!(encode_component(" ") == ~"%20"); - fail_unless!(encode_component("!") == ~"%21"); - fail_unless!(encode_component("#") == ~"%23"); - fail_unless!(encode_component("$") == ~"%24"); - fail_unless!(encode_component("%") == ~"%25"); - fail_unless!(encode_component("&") == ~"%26"); - fail_unless!(encode_component("'") == ~"%27"); - fail_unless!(encode_component("(") == ~"%28"); - fail_unless!(encode_component(")") == ~"%29"); - fail_unless!(encode_component("*") == ~"%2A"); - fail_unless!(encode_component("+") == ~"%2B"); - fail_unless!(encode_component(",") == ~"%2C"); - fail_unless!(encode_component("/") == ~"%2F"); - fail_unless!(encode_component(":") == ~"%3A"); - fail_unless!(encode_component(";") == ~"%3B"); - fail_unless!(encode_component("=") == ~"%3D"); - fail_unless!(encode_component("?") == ~"%3F"); - fail_unless!(encode_component("@") == ~"%40"); - fail_unless!(encode_component("[") == ~"%5B"); - fail_unless!(encode_component("]") == ~"%5D"); + assert!(encode_component(" ") == ~"%20"); + assert!(encode_component("!") == ~"%21"); + assert!(encode_component("#") == ~"%23"); + assert!(encode_component("$") == ~"%24"); + assert!(encode_component("%") == ~"%25"); + assert!(encode_component("&") == ~"%26"); + assert!(encode_component("'") == ~"%27"); + assert!(encode_component("(") == ~"%28"); + assert!(encode_component(")") == ~"%29"); + assert!(encode_component("*") == ~"%2A"); + assert!(encode_component("+") == ~"%2B"); + assert!(encode_component(",") == ~"%2C"); + assert!(encode_component("/") == ~"%2F"); + assert!(encode_component(":") == ~"%3A"); + assert!(encode_component(";") == ~"%3B"); + assert!(encode_component("=") == ~"%3D"); + assert!(encode_component("?") == ~"%3F"); + assert!(encode_component("@") == ~"%40"); + assert!(encode_component("[") == ~"%5B"); + assert!(encode_component("]") == ~"%5D"); } #[test] pub fn test_decode() { - fail_unless!(decode("") == ~""); - fail_unless!(decode("abc/def 123") == ~"abc/def 123"); - fail_unless!(decode("abc%2Fdef%20123") == ~"abc%2Fdef 123"); - fail_unless!(decode("%20") == ~" "); - fail_unless!(decode("%21") == ~"%21"); - fail_unless!(decode("%22") == ~"%22"); - fail_unless!(decode("%23") == ~"%23"); - fail_unless!(decode("%24") == ~"%24"); - fail_unless!(decode("%25") == ~"%"); - fail_unless!(decode("%26") == ~"%26"); - fail_unless!(decode("%27") == ~"'"); - fail_unless!(decode("%28") == ~"%28"); - fail_unless!(decode("%29") == ~"%29"); - fail_unless!(decode("%2A") == ~"%2A"); - fail_unless!(decode("%2B") == ~"%2B"); - fail_unless!(decode("%2C") == ~"%2C"); - fail_unless!(decode("%2F") == ~"%2F"); - fail_unless!(decode("%3A") == ~"%3A"); - fail_unless!(decode("%3B") == ~"%3B"); - fail_unless!(decode("%3D") == ~"%3D"); - fail_unless!(decode("%3F") == ~"%3F"); - fail_unless!(decode("%40") == ~"%40"); - fail_unless!(decode("%5B") == ~"%5B"); - fail_unless!(decode("%5D") == ~"%5D"); + assert!(decode("") == ~""); + assert!(decode("abc/def 123") == ~"abc/def 123"); + assert!(decode("abc%2Fdef%20123") == ~"abc%2Fdef 123"); + assert!(decode("%20") == ~" "); + assert!(decode("%21") == ~"%21"); + assert!(decode("%22") == ~"%22"); + assert!(decode("%23") == ~"%23"); + assert!(decode("%24") == ~"%24"); + assert!(decode("%25") == ~"%"); + assert!(decode("%26") == ~"%26"); + assert!(decode("%27") == ~"'"); + assert!(decode("%28") == ~"%28"); + assert!(decode("%29") == ~"%29"); + assert!(decode("%2A") == ~"%2A"); + assert!(decode("%2B") == ~"%2B"); + assert!(decode("%2C") == ~"%2C"); + assert!(decode("%2F") == ~"%2F"); + assert!(decode("%3A") == ~"%3A"); + assert!(decode("%3B") == ~"%3B"); + assert!(decode("%3D") == ~"%3D"); + assert!(decode("%3F") == ~"%3F"); + assert!(decode("%40") == ~"%40"); + assert!(decode("%5B") == ~"%5B"); + assert!(decode("%5D") == ~"%5D"); } #[test] pub fn test_decode_component() { - fail_unless!(decode_component("") == ~""); - fail_unless!(decode_component("abc/def 123") == ~"abc/def 123"); - fail_unless!(decode_component("abc%2Fdef%20123") == ~"abc/def 123"); - fail_unless!(decode_component("%20") == ~" "); - fail_unless!(decode_component("%21") == ~"!"); - fail_unless!(decode_component("%22") == ~"\""); - fail_unless!(decode_component("%23") == ~"#"); - fail_unless!(decode_component("%24") == ~"$"); - fail_unless!(decode_component("%25") == ~"%"); - fail_unless!(decode_component("%26") == ~"&"); - fail_unless!(decode_component("%27") == ~"'"); - fail_unless!(decode_component("%28") == ~"("); - fail_unless!(decode_component("%29") == ~")"); - fail_unless!(decode_component("%2A") == ~"*"); - fail_unless!(decode_component("%2B") == ~"+"); - fail_unless!(decode_component("%2C") == ~","); - fail_unless!(decode_component("%2F") == ~"/"); - fail_unless!(decode_component("%3A") == ~":"); - fail_unless!(decode_component("%3B") == ~";"); - fail_unless!(decode_component("%3D") == ~"="); - fail_unless!(decode_component("%3F") == ~"?"); - fail_unless!(decode_component("%40") == ~"@"); - fail_unless!(decode_component("%5B") == ~"["); - fail_unless!(decode_component("%5D") == ~"]"); + assert!(decode_component("") == ~""); + assert!(decode_component("abc/def 123") == ~"abc/def 123"); + assert!(decode_component("abc%2Fdef%20123") == ~"abc/def 123"); + assert!(decode_component("%20") == ~" "); + assert!(decode_component("%21") == ~"!"); + assert!(decode_component("%22") == ~"\""); + assert!(decode_component("%23") == ~"#"); + assert!(decode_component("%24") == ~"$"); + assert!(decode_component("%25") == ~"%"); + assert!(decode_component("%26") == ~"&"); + assert!(decode_component("%27") == ~"'"); + assert!(decode_component("%28") == ~"("); + assert!(decode_component("%29") == ~")"); + assert!(decode_component("%2A") == ~"*"); + assert!(decode_component("%2B") == ~"+"); + assert!(decode_component("%2C") == ~","); + assert!(decode_component("%2F") == ~"/"); + assert!(decode_component("%3A") == ~":"); + assert!(decode_component("%3B") == ~";"); + assert!(decode_component("%3D") == ~"="); + assert!(decode_component("%3F") == ~"?"); + assert!(decode_component("%40") == ~"@"); + assert!(decode_component("%5B") == ~"["); + assert!(decode_component("%5D") == ~"]"); } #[test] pub fn test_encode_form_urlencoded() { let mut m = LinearMap::new(); - fail_unless!(encode_form_urlencoded(&m) == ~""); + assert!(encode_form_urlencoded(&m) == ~""); m.insert(~"", ~[]); m.insert(~"foo", ~[]); - fail_unless!(encode_form_urlencoded(&m) == ~""); + assert!(encode_form_urlencoded(&m) == ~""); let mut m = LinearMap::new(); m.insert(~"foo", ~[~"bar", ~"123"]); - fail_unless!(encode_form_urlencoded(&m) == ~"foo=bar&foo=123"); + assert!(encode_form_urlencoded(&m) == ~"foo=bar&foo=123"); let mut m = LinearMap::new(); m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]); - fail_unless!(encode_form_urlencoded(&m) == + assert!(encode_form_urlencoded(&m) == ~"foo+bar=abc&foo+bar=12+%3D+34"); } @@ -1075,13 +1075,13 @@ mod tests { // FIXME #4449: Commented out because this causes an ICE, but only // on FreeBSD /* - fail_unless!(decode_form_urlencoded(~[]).len() == 0); + assert!(decode_form_urlencoded(~[]).len() == 0); let s = str::to_bytes("a=1&foo+bar=abc&foo+bar=12+%3D+34"); let form = decode_form_urlencoded(s); - fail_unless!(form.len() == 2); - fail_unless!(form.get_ref(&~"a") == &~[~"1"]); - fail_unless!(form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"]); + assert!(form.len() == 2); + assert!(form.get_ref(&~"a") == &~[~"1"]); + assert!(form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"]); */ } } diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 6f69ac4e1bd..bb83cfc494b 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -68,7 +68,7 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>( cast::reinterpret_cast(&slice); info!("slice: %?", (base, vec::len(slice), end - base)); - fail_unless!((vec::len(slice) == end - base)); + assert!((vec::len(slice) == end - base)); f(base, slice) } }; @@ -79,12 +79,12 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>( info!("tasks spawned"); info!("num_tasks: %?", (num_tasks, futures.len())); - fail_unless!((num_tasks == futures.len())); + assert!((num_tasks == futures.len())); let r = do futures.map() |ys| { ys.get() }; - fail_unless!((r.len() == futures.len())); + assert!((r.len() == futures.len())); r } } @@ -115,7 +115,7 @@ pub fn mapi<A:Copy + Owned,B:Copy + Owned>( }); let r = vec::concat(slices); info!("%?", (r.len(), xs.len())); - fail_unless!((r.len() == xs.len())); + assert!((r.len() == xs.len())); r } diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index ff00d26882d..1fb79fcab28 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -197,87 +197,87 @@ mod tests { let mut sorted = merge_sort(data, le); let mut heap = from_vec(data); while !heap.is_empty() { - fail_unless!(heap.top() == sorted.last()); - fail_unless!(heap.pop() == sorted.pop()); + assert!(heap.top() == sorted.last()); + assert!(heap.pop() == sorted.pop()); } } #[test] fn test_push() { let mut heap = from_vec(~[2, 4, 9]); - fail_unless!(heap.len() == 3); - fail_unless!(*heap.top() == 9); + assert!(heap.len() == 3); + assert!(*heap.top() == 9); heap.push(11); - fail_unless!(heap.len() == 4); - fail_unless!(*heap.top() == 11); + assert!(heap.len() == 4); + assert!(*heap.top() == 11); heap.push(5); - fail_unless!(heap.len() == 5); - fail_unless!(*heap.top() == 11); + assert!(heap.len() == 5); + assert!(*heap.top() == 11); heap.push(27); - fail_unless!(heap.len() == 6); - fail_unless!(*heap.top() == 27); + assert!(heap.len() == 6); + assert!(*heap.top() == 27); heap.push(3); - fail_unless!(heap.len() == 7); - fail_unless!(*heap.top() == 27); + assert!(heap.len() == 7); + assert!(*heap.top() == 27); heap.push(103); - fail_unless!(heap.len() == 8); - fail_unless!(*heap.top() == 103); + assert!(heap.len() == 8); + assert!(*heap.top() == 103); } #[test] fn test_push_unique() { let mut heap = from_vec(~[~2, ~4, ~9]); - fail_unless!(heap.len() == 3); - fail_unless!(*heap.top() == ~9); + assert!(heap.len() == 3); + assert!(*heap.top() == ~9); heap.push(~11); - fail_unless!(heap.len() == 4); - fail_unless!(*heap.top() == ~11); + assert!(heap.len() == 4); + assert!(*heap.top() == ~11); heap.push(~5); - fail_unless!(heap.len() == 5); - fail_unless!(*heap.top() == ~11); + assert!(heap.len() == 5); + assert!(*heap.top() == ~11); heap.push(~27); - fail_unless!(heap.len() == 6); - fail_unless!(*heap.top() == ~27); + assert!(heap.len() == 6); + assert!(*heap.top() == ~27); heap.push(~3); - fail_unless!(heap.len() == 7); - fail_unless!(*heap.top() == ~27); + assert!(heap.len() == 7); + assert!(*heap.top() == ~27); heap.push(~103); - fail_unless!(heap.len() == 8); - fail_unless!(*heap.top() == ~103); + assert!(heap.len() == 8); + assert!(*heap.top() == ~103); } #[test] fn test_push_pop() { let mut heap = from_vec(~[5, 5, 2, 1, 3]); - fail_unless!(heap.len() == 5); - fail_unless!(heap.push_pop(6) == 6); - fail_unless!(heap.len() == 5); - fail_unless!(heap.push_pop(0) == 5); - fail_unless!(heap.len() == 5); - fail_unless!(heap.push_pop(4) == 5); - fail_unless!(heap.len() == 5); - fail_unless!(heap.push_pop(1) == 4); - fail_unless!(heap.len() == 5); + assert!(heap.len() == 5); + assert!(heap.push_pop(6) == 6); + assert!(heap.len() == 5); + assert!(heap.push_pop(0) == 5); + assert!(heap.len() == 5); + assert!(heap.push_pop(4) == 5); + assert!(heap.len() == 5); + assert!(heap.push_pop(1) == 4); + assert!(heap.len() == 5); } #[test] fn test_replace() { let mut heap = from_vec(~[5, 5, 2, 1, 3]); - fail_unless!(heap.len() == 5); - fail_unless!(heap.replace(6) == 5); - fail_unless!(heap.len() == 5); - fail_unless!(heap.replace(0) == 6); - fail_unless!(heap.len() == 5); - fail_unless!(heap.replace(4) == 5); - fail_unless!(heap.len() == 5); - fail_unless!(heap.replace(1) == 4); - fail_unless!(heap.len() == 5); + assert!(heap.len() == 5); + assert!(heap.replace(6) == 5); + assert!(heap.len() == 5); + assert!(heap.replace(0) == 6); + assert!(heap.len() == 5); + assert!(heap.replace(4) == 5); + assert!(heap.len() == 5); + assert!(heap.replace(1) == 4); + assert!(heap.len() == 5); } fn check_to_vec(data: ~[int]) { let heap = from_vec(data); - fail_unless!(merge_sort(heap.to_vec(), le) == merge_sort(data, le)); - fail_unless!(heap.to_sorted_vec() == merge_sort(data, le)); + assert!(merge_sort(heap.to_vec(), le) == merge_sort(data, le)); + assert!(heap.to_sorted_vec() == merge_sort(data, le)); } #[test] @@ -305,7 +305,7 @@ mod tests { #[test] fn test_empty_maybe_pop() { let mut heap = new::<int>(); - fail_unless!(heap.maybe_pop().is_none()); + assert!(heap.maybe_pop().is_none()); } #[test] @@ -316,7 +316,7 @@ mod tests { #[test] fn test_empty_maybe_top() { let empty = new::<int>(); - fail_unless!(empty.maybe_top().is_none()); + assert!(empty.maybe_top().is_none()); } #[test] diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 51cf08c8ca1..61f50069d89 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -704,7 +704,7 @@ pub mod node { */ pub fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, char_len: uint) -> @Node { - fail_unless!((byte_start + byte_len <= str::len(*str))); + assert!((byte_start + byte_len <= str::len(*str))); let candidate = @Leaf(Leaf { byte_offset: byte_start, byte_len: byte_len, @@ -1313,8 +1313,8 @@ mod tests { #[test] fn trivial() { - fail_unless!(char_len(empty()) == 0u); - fail_unless!(byte_len(empty()) == 0u); + assert!(char_len(empty()) == 0u); + assert!(byte_len(empty()) == 0u); } #[test] @@ -1322,8 +1322,8 @@ mod tests { let sample = @~"0123456789ABCDE"; let r = of_str(sample); - fail_unless!(char_len(r) == str::char_len(*sample)); - fail_unless!(rope_to_string(r) == *sample); + assert!(char_len(r) == str::char_len(*sample)); + assert!(rope_to_string(r) == *sample); } #[test] @@ -1338,8 +1338,8 @@ mod tests { } let sample = @*buf; let r = of_str(sample); - fail_unless!(char_len(r) == str::char_len(*sample)); - fail_unless!(rope_to_string(r) == *sample); + assert!(char_len(r) == str::char_len(*sample)); + assert!(rope_to_string(r) == *sample); let mut string_iter = 0u; let string_len = str::len(*sample); @@ -1359,7 +1359,7 @@ mod tests { } } - fail_unless!(equal); + assert!(equal); } #[test] @@ -1384,7 +1384,7 @@ mod tests { } } - fail_unless!(len == str::char_len(*sample)); + assert!(len == str::char_len(*sample)); } #[test] @@ -1405,11 +1405,11 @@ mod tests { while i < 8 { r2 = append_rope(r2, r2); i+= 1;} - fail_unless!(eq(r1, r2)); + assert!(eq(r1, r2)); let r3 = bal(r2); - fail_unless!(char_len(r1) == char_len(r3)); + assert!(char_len(r1) == char_len(r3)); - fail_unless!(eq(r1, r3)); + assert!(eq(r1, r3)); } #[test] @@ -1426,23 +1426,23 @@ mod tests { for uint::range(0u, char_len(r)) |i| { r2 = append_char(r2, char_at(r, i)); } - fail_unless!(eq(r, r2)); + assert!(eq(r, r2)); let mut r3 = empty(); for uint::range(0u, char_len(r)) |i| { r3 = prepend_char(r3, char_at(r, char_len(r) - i - 1u)); } - fail_unless!(eq(r, r3)); + assert!(eq(r, r3)); //Additional sanity checks let balr = bal(r); let bal2 = bal(r2); let bal3 = bal(r3); - fail_unless!(eq(r, balr)); - fail_unless!(eq(r, bal2)); - fail_unless!(eq(r, bal3)); - fail_unless!(eq(r2, r3)); - fail_unless!(eq(bal2, bal3)); + assert!(eq(r, balr)); + assert!(eq(r, bal2)); + assert!(eq(r, bal3)); + assert!(eq(r2, r3)); + assert!(eq(bal2, bal3)); } #[test] @@ -1457,6 +1457,6 @@ mod tests { //Same rope, obtained with rope::concat let r2 = concat(vec::from_elem(10u, chunk)); - fail_unless!(eq(r, r2)); + assert!(eq(r, r2)); } } diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index 50579db4707..83fab365d8d 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -239,74 +239,74 @@ pub fn parse(s: &str) -> Option<Version> { #[test] fn test_parse() { - fail_unless!(parse("") == None); - fail_unless!(parse(" ") == None); - fail_unless!(parse("1") == None); - fail_unless!(parse("1.2") == None); - fail_unless!(parse("1.2") == None); - fail_unless!(parse("1") == None); - fail_unless!(parse("1.2") == None); - fail_unless!(parse("1.2.3-") == None); - fail_unless!(parse("a.b.c") == None); - fail_unless!(parse("1.2.3 abc") == None); - - fail_unless!(parse("1.2.3") == Some(Version { + assert!(parse("") == None); + assert!(parse(" ") == None); + assert!(parse("1") == None); + assert!(parse("1.2") == None); + assert!(parse("1.2") == None); + assert!(parse("1") == None); + assert!(parse("1.2") == None); + assert!(parse("1.2.3-") == None); + assert!(parse("a.b.c") == None); + assert!(parse("1.2.3 abc") == None); + + assert!(parse("1.2.3") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[], })); - fail_unless!(parse(" 1.2.3 ") == Some(Version { + assert!(parse(" 1.2.3 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[], })); - fail_unless!(parse("1.2.3-alpha1") == Some(Version { + assert!(parse("1.2.3-alpha1") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[] })); - fail_unless!(parse(" 1.2.3-alpha1 ") == Some(Version { + assert!(parse(" 1.2.3-alpha1 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[] })); - fail_unless!(parse("1.2.3+build5") == Some(Version { + assert!(parse("1.2.3+build5") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[AlphaNumeric(~"build5")] })); - fail_unless!(parse(" 1.2.3+build5 ") == Some(Version { + assert!(parse(" 1.2.3+build5 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[AlphaNumeric(~"build5")] })); - fail_unless!(parse("1.2.3-alpha1+build5") == Some(Version { + assert!(parse("1.2.3-alpha1+build5") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[AlphaNumeric(~"build5")] })); - fail_unless!(parse(" 1.2.3-alpha1+build5 ") == Some(Version { + assert!(parse(" 1.2.3-alpha1+build5 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[AlphaNumeric(~"build5")] })); - fail_unless!(parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Some(Version { + assert!(parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Some(Version { major: 1u, minor: 2u, patch: 3u, @@ -320,54 +320,54 @@ fn test_parse() { #[test] fn test_eq() { - fail_unless!(parse("1.2.3") == parse("1.2.3")); - fail_unless!(parse("1.2.3-alpha1") == parse("1.2.3-alpha1")); + assert!(parse("1.2.3") == parse("1.2.3")); + assert!(parse("1.2.3-alpha1") == parse("1.2.3-alpha1")); } #[test] fn test_ne() { - fail_unless!(parse("0.0.0") != parse("0.0.1")); - fail_unless!(parse("0.0.0") != parse("0.1.0")); - fail_unless!(parse("0.0.0") != parse("1.0.0")); - fail_unless!(parse("1.2.3-alpha") != parse("1.2.3-beta")); + assert!(parse("0.0.0") != parse("0.0.1")); + assert!(parse("0.0.0") != parse("0.1.0")); + assert!(parse("0.0.0") != parse("1.0.0")); + assert!(parse("1.2.3-alpha") != parse("1.2.3-beta")); } #[test] fn test_lt() { - fail_unless!(parse("0.0.0") < parse("1.2.3-alpha2")); - fail_unless!(parse("1.0.0") < parse("1.2.3-alpha2")); - fail_unless!(parse("1.2.0") < parse("1.2.3-alpha2")); - fail_unless!(parse("1.2.3-alpha1") < parse("1.2.3")); - fail_unless!(parse("1.2.3-alpha1") < parse("1.2.3-alpha2")); - fail_unless!(!(parse("1.2.3-alpha2") < parse("1.2.3-alpha2"))); + assert!(parse("0.0.0") < parse("1.2.3-alpha2")); + assert!(parse("1.0.0") < parse("1.2.3-alpha2")); + assert!(parse("1.2.0") < parse("1.2.3-alpha2")); + assert!(parse("1.2.3-alpha1") < parse("1.2.3")); + assert!(parse("1.2.3-alpha1") < parse("1.2.3-alpha2")); + assert!(!(parse("1.2.3-alpha2") < parse("1.2.3-alpha2"))); } #[test] fn test_le() { - fail_unless!(parse("0.0.0") <= parse("1.2.3-alpha2")); - fail_unless!(parse("1.0.0") <= parse("1.2.3-alpha2")); - fail_unless!(parse("1.2.0") <= parse("1.2.3-alpha2")); - fail_unless!(parse("1.2.3-alpha1") <= parse("1.2.3-alpha2")); - fail_unless!(parse("1.2.3-alpha2") <= parse("1.2.3-alpha2")); + assert!(parse("0.0.0") <= parse("1.2.3-alpha2")); + assert!(parse("1.0.0") <= parse("1.2.3-alpha2")); + assert!(parse("1.2.0") <= parse("1.2.3-alpha2")); + assert!(parse("1.2.3-alpha1") <= parse("1.2.3-alpha2")); + assert!(parse("1.2.3-alpha2") <= parse("1.2.3-alpha2")); } #[test] fn test_gt() { - fail_unless!(parse("1.2.3-alpha2") > parse("0.0.0")); - fail_unless!(parse("1.2.3-alpha2") > parse("1.0.0")); - fail_unless!(parse("1.2.3-alpha2") > parse("1.2.0")); - fail_unless!(parse("1.2.3-alpha2") > parse("1.2.3-alpha1")); - fail_unless!(parse("1.2.3") > parse("1.2.3-alpha2")); - fail_unless!(!(parse("1.2.3-alpha2") > parse("1.2.3-alpha2"))); + assert!(parse("1.2.3-alpha2") > parse("0.0.0")); + assert!(parse("1.2.3-alpha2") > parse("1.0.0")); + assert!(parse("1.2.3-alpha2") > parse("1.2.0")); + assert!(parse("1.2.3-alpha2") > parse("1.2.3-alpha1")); + assert!(parse("1.2.3") > parse("1.2.3-alpha2")); + assert!(!(parse("1.2.3-alpha2") > parse("1.2.3-alpha2"))); } #[test] fn test_ge() { - fail_unless!(parse("1.2.3-alpha2") >= parse("0.0.0")); - fail_unless!(parse("1.2.3-alpha2") >= parse("1.0.0")); - fail_unless!(parse("1.2.3-alpha2") >= parse("1.2.0")); - fail_unless!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha1")); - fail_unless!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha2")); + assert!(parse("1.2.3-alpha2") >= parse("0.0.0")); + assert!(parse("1.2.3-alpha2") >= parse("1.0.0")); + assert!(parse("1.2.3-alpha2") >= parse("1.2.0")); + assert!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha1")); + assert!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha2")); } #[test] @@ -388,7 +388,7 @@ fn test_spec_order() { while i < vs.len() { let a = parse(vs[i-1]).get(); let b = parse(vs[i]).get(); - fail_unless!(a < b); + assert!(a < b); i += 1; } } diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index fb56abc1b64..360ec8afe51 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -401,7 +401,7 @@ impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> for (T0, T1) { impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> for (T0, T1) { fn decode(d: &D) -> (T0, T1) { do d.read_seq |len| { - fail_unless!(len == 2); + assert!(len == 2); ( d.read_seq_elt(0, || Decodable::decode(d)), d.read_seq_elt(1, || Decodable::decode(d)) @@ -437,7 +437,7 @@ impl< > Decodable<D> for (T0, T1, T2) { fn decode(d: &D) -> (T0, T1, T2) { do d.read_seq |len| { - fail_unless!(len == 3); + assert!(len == 3); ( d.read_seq_elt(0, || Decodable::decode(d)), d.read_seq_elt(1, || Decodable::decode(d)), @@ -477,7 +477,7 @@ impl< > Decodable<D> for (T0, T1, T2, T3) { fn decode(d: &D) -> (T0, T1, T2, T3) { do d.read_seq |len| { - fail_unless!(len == 4); + assert!(len == 4); ( d.read_seq_elt(0, || Decodable::decode(d)), d.read_seq_elt(1, || Decodable::decode(d)), @@ -522,7 +522,7 @@ impl< fn decode(d: &D) -> (T0, T1, T2, T3, T4) { do d.read_seq |len| { - fail_unless!(len == 5); + assert!(len == 5); ( d.read_seq_elt(0, || Decodable::decode(d)), d.read_seq_elt(1, || Decodable::decode(d)), diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index b603e2eb1cc..1a2d4a87d98 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -74,7 +74,7 @@ pub fn sha1() -> @Sha1 { work_buf: @mut ~[u32]}; fn add_input(st: &mut Sha1State, msg: &const [u8]) { - fail_unless!((!st.computed)); + assert!((!st.computed)); for vec::each_const(msg) |element| { st.msg_block[st.msg_block_idx] = *element; st.msg_block_idx += 1u; @@ -90,8 +90,8 @@ pub fn sha1() -> @Sha1 { } } fn process_msg_block(st: &mut Sha1State) { - fail_unless!((vec::len(st.h) == digest_buf_len)); - fail_unless!((vec::uniq_len(st.work_buf) == work_buf_len)); + assert!((vec::len(st.h) == digest_buf_len)); + assert!((vec::uniq_len(st.work_buf) == work_buf_len)); let mut t: int; // Loop counter let mut w = st.work_buf; @@ -192,7 +192,7 @@ pub fn sha1() -> @Sha1 { * can be assumed that the message digest has been computed. */ fn pad_msg(st: &mut Sha1State) { - fail_unless!((vec::len((*st).msg_block) == msg_block_len)); + assert!((vec::len((*st).msg_block) == msg_block_len)); /* * Check to see if the current message block is too small to hold @@ -230,7 +230,7 @@ pub fn sha1() -> @Sha1 { impl Sha1 for Sha1State { fn reset(&mut self) { - fail_unless!((vec::len(self.h) == digest_buf_len)); + assert!((vec::len(self.h) == digest_buf_len)); self.len_low = 0u32; self.len_high = 0u32; self.msg_block_idx = 0u; @@ -366,13 +366,13 @@ mod tests { ]; let tests = fips_180_1_tests + wikipedia_tests; fn check_vec_eq(v0: ~[u8], v1: ~[u8]) { - fail_unless!((vec::len::<u8>(v0) == vec::len::<u8>(v1))); + assert!((vec::len::<u8>(v0) == vec::len::<u8>(v1))); let len = vec::len::<u8>(v0); let mut i = 0u; while i < len { let a = v0[i]; let b = v1[i]; - fail_unless!((a == b)); + assert!((a == b)); i += 1u; } } @@ -385,8 +385,8 @@ mod tests { check_vec_eq(t.output, out); let out_str = sh.result_str(); - fail_unless!((out_str.len() == 40)); - fail_unless!((out_str == t.output_str)); + assert!((out_str.len() == 40)); + assert!((out_str == t.output_str)); sh.reset(); } @@ -406,8 +406,8 @@ mod tests { check_vec_eq(t.output, out); let out_str = sh.result_str(); - fail_unless!((out_str.len() == 40)); - fail_unless!((out_str == t.output_str)); + assert!((out_str.len() == 40)); + assert!((out_str == t.output_str)); sh.reset(); } diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 16f7c0ba860..b6c5ec03068 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -177,9 +177,9 @@ mod tests { #[test] fn test_find_mut() { let mut m = SmallIntMap::new(); - fail_unless!(m.insert(1, 12)); - fail_unless!(m.insert(2, 8)); - fail_unless!(m.insert(5, 14)); + assert!(m.insert(1, 12)); + assert!(m.insert(2, 8)); + assert!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -190,30 +190,30 @@ mod tests { #[test] fn test_len() { let mut map = SmallIntMap::new(); - fail_unless!(map.len() == 0); - fail_unless!(map.is_empty()); - fail_unless!(map.insert(5, 20)); - fail_unless!(map.len() == 1); - fail_unless!(!map.is_empty()); - fail_unless!(map.insert(11, 12)); - fail_unless!(map.len() == 2); - fail_unless!(!map.is_empty()); - fail_unless!(map.insert(14, 22)); - fail_unless!(map.len() == 3); - fail_unless!(!map.is_empty()); + assert!(map.len() == 0); + assert!(map.is_empty()); + assert!(map.insert(5, 20)); + assert!(map.len() == 1); + assert!(!map.is_empty()); + assert!(map.insert(11, 12)); + assert!(map.len() == 2); + assert!(!map.is_empty()); + assert!(map.insert(14, 22)); + assert!(map.len() == 3); + assert!(!map.is_empty()); } #[test] fn test_clear() { let mut map = SmallIntMap::new(); - fail_unless!(map.insert(5, 20)); - fail_unless!(map.insert(11, 12)); - fail_unless!(map.insert(14, 22)); + assert!(map.insert(5, 20)); + assert!(map.insert(11, 12)); + assert!(map.insert(14, 22)); map.clear(); - fail_unless!(map.is_empty()); - fail_unless!(map.find(&5).is_none()); - fail_unless!(map.find(&11).is_none()); - fail_unless!(map.find(&14).is_none()); + assert!(map.is_empty()); + assert!(map.find(&5).is_none()); + assert!(map.find(&11).is_none()); + assert!(map.find(&14).is_none()); } #[test] @@ -238,11 +238,11 @@ mod tests { map.update_with_key(3, 2, addMoreToCount); // check the total counts - fail_unless!(map.find(&3).get() == &10); - fail_unless!(map.find(&5).get() == &3); - fail_unless!(map.find(&9).get() == &1); + assert!(map.find(&3).get() == &10); + assert!(map.find(&5).get() == &3); + assert!(map.find(&9).get() == &1); // sadly, no sevens were counted - fail_unless!(map.find(&7).is_none()); + assert!(map.find(&7).is_none()); } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 761a17352a9..40a12895175 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -223,7 +223,7 @@ pub fn tim_sort<T:Copy + Ord>(array: &mut [T]) { fn binarysort<T:Copy + Ord>(array: &mut [T], start: uint) { let size = array.len(); let mut start = start; - fail_unless!(start <= size); + assert!(start <= size); if start == 0 { start += 1; } @@ -231,7 +231,7 @@ fn binarysort<T:Copy + Ord>(array: &mut [T], start: uint) { let pivot = array[start]; let mut left = 0; let mut right = start; - fail_unless!(left <= right); + assert!(left <= right); while left < right { let mid = (left + right) >> 1; @@ -241,7 +241,7 @@ fn binarysort<T:Copy + Ord>(array: &mut [T], start: uint) { left = mid+1; } } - fail_unless!(left == right); + assert!(left == right); let mut n = start-left; copy_vec(array, left+1, array, left, n); @@ -272,7 +272,7 @@ fn min_run_length(n: uint) -> uint { fn count_run_ascending<T:Copy + Ord>(array: &mut [T]) -> uint { let size = array.len(); - fail_unless!(size > 0); + assert!(size > 0); if size == 1 { return 1; } let mut run = 2; @@ -295,7 +295,7 @@ fn gallop_left<T:Copy + Ord>(key: &const T, hint: uint) -> uint { let size = array.len(); - fail_unless!(size != 0 && hint < size); + assert!(size != 0 && hint < size); let mut last_ofs = 0; let mut ofs = 1; @@ -326,7 +326,7 @@ fn gallop_left<T:Copy + Ord>(key: &const T, last_ofs = hint - ofs; ofs = hint - tmp; } - fail_unless!((last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size); + assert!((last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size); last_ofs += 1; while last_ofs < ofs { @@ -337,7 +337,7 @@ fn gallop_left<T:Copy + Ord>(key: &const T, ofs = m; } } - fail_unless!(last_ofs == ofs); + assert!(last_ofs == ofs); return ofs; } @@ -346,7 +346,7 @@ fn gallop_right<T:Copy + Ord>(key: &const T, hint: uint) -> uint { let size = array.len(); - fail_unless!(size != 0 && hint < size); + assert!(size != 0 && hint < size); let mut last_ofs = 0; let mut ofs = 1; @@ -378,7 +378,7 @@ fn gallop_right<T:Copy + Ord>(key: &const T, ofs = hint - tmp; } - fail_unless!((last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size); + assert!((last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size); last_ofs += 1; while last_ofs < ofs { @@ -390,7 +390,7 @@ fn gallop_right<T:Copy + Ord>(key: &const T, ofs = m; } } - fail_unless!(last_ofs == ofs); + assert!(last_ofs == ofs); return ofs; } @@ -420,16 +420,16 @@ impl<T:Copy + Ord> MergeState<T> { fn merge_at(&mut self, n: uint, array: &mut [T]) { let mut size = self.runs.len(); - fail_unless!(size >= 2); - fail_unless!(n == size-2 || n == size-3); + assert!(size >= 2); + assert!(n == size-2 || n == size-3); let mut b1 = self.runs[n].base; let mut l1 = self.runs[n].len; let b2 = self.runs[n+1].base; let l2 = self.runs[n+1].len; - fail_unless!(l1 > 0 && l2 > 0); - fail_unless!(b1 + l1 == b2); + assert!(l1 > 0 && l2 > 0); + assert!(b1 + l1 == b2); self.runs[n].len = l1 + l2; if n == size-3 { @@ -458,7 +458,7 @@ impl<T:Copy + Ord> MergeState<T> { fn merge_lo(&mut self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { - fail_unless!(len1 != 0 && len2 != 0 && base1+len1 == base2); + assert!(len1 != 0 && len2 != 0 && base1+len1 == base2); let mut tmp = ~[]; for uint::range(base1, base1+len1) |i| { @@ -491,7 +491,7 @@ impl<T:Copy + Ord> MergeState<T> { let mut break_outer = false; loop { - fail_unless!(len1 > 1 && len2 != 0); + assert!(len1 > 1 && len2 != 0); if array[c2] < tmp[c1] { array[dest] <-> array[c2]; dest += 1; c2 += 1; len2 -= 1; @@ -515,7 +515,7 @@ impl<T:Copy + Ord> MergeState<T> { // Start to gallop loop { - fail_unless!(len1 > 1 && len2 != 0); + assert!(len1 > 1 && len2 != 0); let tmp_view = vec::const_slice(tmp, c1, c1+len1); count1 = gallop_right(&const array[c2], tmp_view, 0); @@ -550,21 +550,21 @@ impl<T:Copy + Ord> MergeState<T> { self.min_gallop = if min_gallop < 1 { 1 } else { min_gallop }; if len1 == 1 { - fail_unless!(len2 > 0); + assert!(len2 > 0); copy_vec(array, dest, array, c2, len2); array[dest+len2] <-> tmp[c1]; } else if len1 == 0 { fail!(~"Comparison violates its contract!"); } else { - fail_unless!(len2 == 0); - fail_unless!(len1 > 1); + assert!(len2 == 0); + assert!(len1 > 1); copy_vec(array, dest, tmp, c1, len1); } } fn merge_hi(&mut self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { - fail_unless!(len1 != 1 && len2 != 0 && base1 + len1 == base2); + assert!(len1 != 1 && len2 != 0 && base1 + len1 == base2); let mut tmp = ~[]; for uint::range(base2, base2+len2) |i| { @@ -599,7 +599,7 @@ impl<T:Copy + Ord> MergeState<T> { let mut break_outer = false; loop { - fail_unless!(len1 != 0 && len2 > 1); + assert!(len1 != 0 && len2 > 1); if tmp[c2] < array[c1] { array[dest] <-> array[c1]; dest -= 1; c1 -= 1; len1 -= 1; @@ -623,7 +623,7 @@ impl<T:Copy + Ord> MergeState<T> { // Start to gallop loop { - fail_unless!(len2 > 1 && len1 != 0); + assert!(len2 > 1 && len1 != 0); let tmp_view = vec::mut_slice(array, base1, base1+len1); count1 = len1 - gallop_right( @@ -669,7 +669,7 @@ impl<T:Copy + Ord> MergeState<T> { self.min_gallop = if min_gallop < 1 { 1 } else { min_gallop }; if len2 == 1 { - fail_unless!(len1 > 0); + assert!(len1 > 0); dest -= len1; c1 -= len1; copy_vec(array, dest+1, array, c1+1, len1); @@ -677,8 +677,8 @@ impl<T:Copy + Ord> MergeState<T> { } else if len2 == 0 { fail!(~"Comparison violates its contract!"); } else { - fail_unless!(len1 == 0); - fail_unless!(len2 != 0); + assert!(len1 == 0); + assert!(len2 != 0); copy_vec(array, dest-(len2-1), tmp, 0, len2); } } @@ -718,7 +718,7 @@ fn copy_vec<T:Copy>(dest: &mut [T], from: &const [T], s2: uint, len: uint) { - fail_unless!(s1+len <= dest.len() && s2+len <= from.len()); + assert!(s1+len <= dest.len() && s2+len <= from.len()); let mut slice = ~[]; for uint::range(s2, s2+len) |i| { @@ -742,7 +742,7 @@ mod test_qsort3 { let mut i = 0; while i < len { // debug!(v2[i]); - fail_unless!((v2[i] == v1[i])); + assert!((v2[i] == v1[i])); i += 1; } } @@ -787,7 +787,7 @@ mod test_qsort { let mut i = 0u; while i < len { // debug!(v2[i]); - fail_unless!((v2[i] == v1[i])); + assert!((v2[i] == v1[i])); i += 1; } } @@ -832,7 +832,7 @@ mod test_qsort { for vec::each(pairs) |p| { let (a, b) = *p; debug!("%d %d", a, b); - fail_unless!((a == b)); + assert!((a == b)); } } } @@ -853,7 +853,7 @@ mod tests { let mut i = 0u; while i < len { debug!(v3[i]); - fail_unless!((v3[i] == v2[i])); + assert!((v3[i] == v2[i])); i += 1; } } @@ -880,7 +880,7 @@ mod tests { pub fn le(a: &int, b: &int) -> bool { *a <= *b } let mut v1 = ~[3, 2, 1]; let v2 = merge_sort(v1, le); - fail_unless!(v2 == ~[1, 2, 3]); + assert!(v2 == ~[1, 2, 3]); } #[test] @@ -901,7 +901,7 @@ mod tests { let names2 = ~["Alex Andy", "Jack Brown", "joe bob", "Joe Bob", "JOE Bob", "JOE BOB", "Sally Mae"]; let names3 = merge_sort(names1, ile); - fail_unless!(names3 == names2); + assert!(names3 == names2); } } @@ -938,7 +938,7 @@ mod test_tim_sort { let mut i = 0u; while i < len { // debug!(v2[i]); - fail_unless!((v2[i] == v1[i])); + assert!((v2[i] == v1[i])); i += 1u; } } diff --git a/src/libstd/stats.rs b/src/libstd/stats.rs index 04059a49511..6513a671ab3 100644 --- a/src/libstd/stats.rs +++ b/src/libstd/stats.rs @@ -36,22 +36,22 @@ impl<'self> Stats for &'self [f64] { } fn min(self) -> f64 { - fail_unless!(self.len() != 0); + assert!(self.len() != 0); vec::foldl(self[0], self, |p,q| cmp::min(p, *q)) } fn max(self) -> f64 { - fail_unless!(self.len() != 0); + assert!(self.len() != 0); vec::foldl(self[0], self, |p,q| cmp::max(p, *q)) } fn mean(self) -> f64 { - fail_unless!(self.len() != 0); + assert!(self.len() != 0); self.sum() / (self.len() as f64) } fn median(self) -> f64 { - fail_unless!(self.len() != 0); + assert!(self.len() != 0); let mut tmp = vec::from_slice(self); sort::tim_sort(tmp); if tmp.len() & 1 == 0 { diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index ea9455b1e98..99b3a122d9f 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -595,7 +595,7 @@ pub impl RWlock { do task::unkillable { let mut first_reader = false; do self.state.with |state| { - fail_unless!(!state.read_mode); + assert!(!state.read_mode); state.read_mode = true; first_reader = (state.read_count == 0); state.read_count += 1; @@ -626,8 +626,8 @@ impl<'self> Drop for RWlockReleaseRead<'self> { do task::unkillable { let mut last_reader = false; do self.lock.state.with |state| { - fail_unless!(state.read_mode); - fail_unless!(state.read_count > 0); + assert!(state.read_mode); + assert!(state.read_count > 0); state.read_count -= 1; if state.read_count == 0 { last_reader = true; @@ -663,7 +663,7 @@ impl<'self> Drop for RWlockReleaseDowngrade<'self> { let mut writer_or_last_reader = false; do self.lock.state.with |state| { if state.read_mode { - fail_unless!(state.read_count > 0); + assert!(state.read_count > 0); state.read_count -= 1; if state.read_count == 0 { // Case 1: Writer downgraded & was the last reader @@ -852,7 +852,7 @@ mod tests { access_shared(sharedstate, m, 10); let _ = p.recv(); - fail_unless!(*sharedstate == 20); + assert!(*sharedstate == 20); fn access_shared(sharedstate: &mut int, m: &Mutex, n: uint) { for n.times { @@ -874,7 +874,7 @@ mod tests { do task::spawn || { do m2.lock_cond |cond| { let woken = cond.signal(); - fail_unless!(woken); + assert!(woken); } } cond.wait(); @@ -892,7 +892,7 @@ mod tests { let _ = port.recv(); // Wait until child gets in the mutex do m.lock_cond |cond| { let woken = cond.signal(); - fail_unless!(woken); + assert!(woken); } let _ = port.recv(); // Wait until child wakes up } @@ -918,7 +918,7 @@ mod tests { for ports.each |port| { let _ = port.recv(); } do m.lock_cond |cond| { let num_woken = cond.broadcast(); - fail_unless!(num_woken == num_waiters); + assert!(num_woken == num_waiters); } // wait until all children wake up for ports.each |port| { let _ = port.recv(); } @@ -939,7 +939,7 @@ mod tests { do m.lock_cond |_x| { } }; do m2.lock_cond |cond| { - fail_unless!(!cond.signal()); + assert!(!cond.signal()); } } #[test] #[ignore(cfg(windows))] @@ -953,7 +953,7 @@ mod tests { fail!(); } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); // child task must have finished by the time try returns do m.lock { } } @@ -976,11 +976,11 @@ mod tests { cond.wait(); // block forever } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); // child task must have finished by the time try returns do m.lock_cond |cond| { let woken = cond.signal(); - fail_unless!(!woken); + assert!(!woken); } } #[test] #[ignore(cfg(windows))] @@ -1013,12 +1013,12 @@ mod tests { c.send(sibling_convos); // let parent wait on all children fail!(); }; - fail_unless!(result.is_err()); + assert!(result.is_err()); // child task must have finished by the time try returns for vec::each(p.recv()) |p| { p.recv(); } // wait on all its siblings do m.lock_cond |cond| { let woken = cond.broadcast(); - fail_unless!(woken == 0); + assert!(woken == 0); } struct SendOnFailure { c: comm::Chan<()>, @@ -1069,7 +1069,7 @@ mod tests { } } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); } #[test] #[ignore(cfg(windows))] pub fn test_mutex_no_condvars() { @@ -1077,17 +1077,17 @@ mod tests { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.wait(); } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); let result = do task::try { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.signal(); } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); let result = do task::try { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.broadcast(); } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); } /************************************************************************ * Reader/writer lock tests @@ -1129,7 +1129,7 @@ mod tests { access_shared(sharedstate, x, mode2, 10); let _ = p.recv(); - fail_unless!(*sharedstate == 20); + assert!(*sharedstate == 20); fn access_shared(sharedstate: &mut int, x: &RWlock, mode: RWlockMode, n: uint) { @@ -1223,7 +1223,7 @@ mod tests { do task::spawn || { do x2.write_cond |cond| { let woken = cond.signal(); - fail_unless!(woken); + assert!(woken); } } cond.wait(); @@ -1242,7 +1242,7 @@ mod tests { do x.read { } // Must be able to get in as a reader in the meantime do x.write_cond |cond| { // Or as another writer let woken = cond.signal(); - fail_unless!(woken); + assert!(woken); } let _ = port.recv(); // Wait until child wakes up do x.read { } // Just for good measure @@ -1281,7 +1281,7 @@ mod tests { for ports.each |port| { let _ = port.recv(); } do lock_cond(x, dg2) |cond| { let num_woken = cond.broadcast(); - fail_unless!(num_woken == num_waiters); + assert!(num_woken == num_waiters); } // wait until all children wake up for ports.each |port| { let _ = port.recv(); } @@ -1308,7 +1308,7 @@ mod tests { fail!(); } }; - fail_unless!(result.is_err()); + assert!(result.is_err()); // child task must have finished by the time try returns do lock_rwlock_in_mode(x, mode2) { } } diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index dbfe3d6a8b5..aed6721b78e 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -49,7 +49,7 @@ pub impl<T> TaskPool<T> { opt_sched_mode: Option<SchedMode>, init_fn_factory: ~fn() -> ~fn(uint) -> T) -> TaskPool<T> { - fail_unless!(n_tasks >= 1); + assert!(n_tasks >= 1); let channels = do vec::from_fn(n_tasks) |i| { let (port, chan) = comm::stream::<Msg<T>>(); diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 7704ec158e5..895ccbc820b 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -30,5 +30,5 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> { fn test_mkdtemp() { let p = mkdtemp(&Path("."), "foobar").unwrap(); os::remove_dir(&p); - fail_unless!(str::ends_with(p.to_str(), "foobar")); + assert!(str::ends_with(p.to_str(), "foobar")); } diff --git a/src/libstd/term.rs b/src/libstd/term.rs index a6c8884e05d..022f1f8564e 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -60,7 +60,7 @@ pub fn color_supported() -> bool { } pub fn set_color(writer: @io::Writer, first_char: u8, color: u8) { - fail_unless!((color < 16u8)); + assert!((color < 16u8)); esc(writer); let mut color = color; if color >= 8u8 { writer.write(~['1' as u8, ';' as u8]); color -= 8u8; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 853a17abb55..7c5591d839e 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -282,7 +282,7 @@ pub fn run_tests_console(opts: &TestOpts, run_tests(opts, tests, |x| callback(&x, st)); - fail_unless!(st.passed + st.failed + + assert!(st.passed + st.failed + st.ignored + st.benchmarked == st.total); let success = st.failed == 0u; @@ -403,7 +403,7 @@ fn should_sort_failures_before_printing_them() { let apos = str::find_str(s, ~"a").get(); let bpos = str::find_str(s, ~"b").get(); - fail_unless!(apos < bpos); + assert!(apos < bpos); } fn use_color() -> bool { return get_concurrency() == 1; } @@ -797,7 +797,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - fail_unless!(res != TrOk); + assert!(res != TrOk); } #[test] @@ -815,7 +815,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - fail_unless!(res == TrIgnored); + assert!(res == TrIgnored); } #[test] @@ -834,7 +834,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - fail_unless!(res == TrOk); + assert!(res == TrOk); } #[test] @@ -852,7 +852,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - fail_unless!(res == TrFailed); + assert!(res == TrFailed); } #[test] @@ -862,7 +862,7 @@ mod tests { either::Left(copy o) => o, _ => fail!(~"Malformed arg in first_free_arg_should_be_a_filter") }; - fail_unless!(~"filter" == opts.filter.get()); + assert!(~"filter" == opts.filter.get()); } #[test] @@ -872,7 +872,7 @@ mod tests { either::Left(copy o) => o, _ => fail!(~"Malformed arg in parse_ignored_flag") }; - fail_unless!((opts.run_ignored)); + assert!((opts.run_ignored)); } #[test] @@ -912,9 +912,9 @@ mod tests { ]; let filtered = filter_tests(&opts, tests); - fail_unless!((vec::len(filtered) == 1)); - fail_unless!((filtered[0].desc.name.to_str() == ~"1")); - fail_unless!((filtered[0].desc.ignore == false)); + assert!((vec::len(filtered) == 1)); + assert!((filtered[0].desc.name.to_str() == ~"1")); + assert!((filtered[0].desc.ignore == false)); } #[test] @@ -969,7 +969,7 @@ mod tests { for vec::each(pairs) |p| { match *p { (ref a, ref b) => { - fail_unless!((*a == b.desc.name.to_str())); + assert!((*a == b.desc.name.to_str())); } } } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 9ac302ed890..3af193e8748 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -53,7 +53,7 @@ pub struct Timespec { sec: i64, nsec: i32 } */ pub impl Timespec { fn new(sec: i64, nsec: i32) -> Timespec { - fail_unless!(nsec >= 0 && nsec < NSEC_PER_SEC); + assert!(nsec >= 0 && nsec < NSEC_PER_SEC); Timespec { sec: sec, nsec: nsec } } } @@ -883,17 +883,17 @@ mod tests { let tv1 = get_time(); debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint); - fail_unless!(tv1.sec > some_recent_date); - fail_unless!(tv1.nsec < 1000000000i32); + assert!(tv1.sec > some_recent_date); + assert!(tv1.nsec < 1000000000i32); let tv2 = get_time(); debug!("tv2=%? sec + %? nsec", tv2.sec as uint, tv2.nsec as uint); - fail_unless!(tv2.sec >= tv1.sec); - fail_unless!(tv2.sec < some_future_date); - fail_unless!(tv2.nsec < 1000000000i32); + assert!(tv2.sec >= tv1.sec); + assert!(tv2.sec < some_future_date); + assert!(tv2.nsec < 1000000000i32); if tv2.sec == tv1.sec { - fail_unless!(tv2.nsec >= tv1.nsec); + assert!(tv2.nsec >= tv1.nsec); } } @@ -902,16 +902,16 @@ mod tests { let ns1 = precise_time_ns(); debug!("s0=%s sec", float::to_str_digits(s0, 9u)); - fail_unless!(s0 > 0.); + assert!(s0 > 0.); let ns0 = (s0 * 1000000000.) as u64; debug!("ns0=%? ns", ns0); debug!("ns1=%? ns", ns0); - fail_unless!(ns1 >= ns0); + assert!(ns1 >= ns0); let ns2 = precise_time_ns(); debug!("ns2=%? ns", ns0); - fail_unless!(ns2 >= ns1); + assert!(ns2 >= ns1); } pub fn test_at_utc() { @@ -921,18 +921,18 @@ mod tests { let time = ::time::Timespec::new(1234567890, 54321); let utc = at_utc(time); - fail_unless!(utc.tm_sec == 30_i32); - fail_unless!(utc.tm_min == 31_i32); - fail_unless!(utc.tm_hour == 23_i32); - fail_unless!(utc.tm_mday == 13_i32); - fail_unless!(utc.tm_mon == 1_i32); - fail_unless!(utc.tm_year == 109_i32); - fail_unless!(utc.tm_wday == 5_i32); - fail_unless!(utc.tm_yday == 43_i32); - fail_unless!(utc.tm_isdst == 0_i32); - fail_unless!(utc.tm_gmtoff == 0_i32); - fail_unless!(utc.tm_zone == ~"UTC"); - fail_unless!(utc.tm_nsec == 54321_i32); + assert!(utc.tm_sec == 30_i32); + assert!(utc.tm_min == 31_i32); + assert!(utc.tm_hour == 23_i32); + assert!(utc.tm_mday == 13_i32); + assert!(utc.tm_mon == 1_i32); + assert!(utc.tm_year == 109_i32); + assert!(utc.tm_wday == 5_i32); + assert!(utc.tm_yday == 43_i32); + assert!(utc.tm_isdst == 0_i32); + assert!(utc.tm_gmtoff == 0_i32); + assert!(utc.tm_zone == ~"UTC"); + assert!(utc.tm_nsec == 54321_i32); } pub fn test_at() { @@ -944,23 +944,23 @@ mod tests { error!("time_at: %?", local); - fail_unless!(local.tm_sec == 30_i32); - fail_unless!(local.tm_min == 31_i32); - fail_unless!(local.tm_hour == 15_i32); - fail_unless!(local.tm_mday == 13_i32); - fail_unless!(local.tm_mon == 1_i32); - fail_unless!(local.tm_year == 109_i32); - fail_unless!(local.tm_wday == 5_i32); - fail_unless!(local.tm_yday == 43_i32); - fail_unless!(local.tm_isdst == 0_i32); - fail_unless!(local.tm_gmtoff == -28800_i32); + assert!(local.tm_sec == 30_i32); + assert!(local.tm_min == 31_i32); + assert!(local.tm_hour == 15_i32); + assert!(local.tm_mday == 13_i32); + assert!(local.tm_mon == 1_i32); + assert!(local.tm_year == 109_i32); + assert!(local.tm_wday == 5_i32); + assert!(local.tm_yday == 43_i32); + assert!(local.tm_isdst == 0_i32); + assert!(local.tm_gmtoff == -28800_i32); // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = &local.tm_zone; - fail_unless!(*zone == ~"PST" || *zone == ~"Pacific Standard Time"); + assert!(*zone == ~"PST" || *zone == ~"Pacific Standard Time"); - fail_unless!(local.tm_nsec == 54321_i32); + assert!(local.tm_nsec == 54321_i32); } pub fn test_to_timespec() { @@ -970,8 +970,8 @@ mod tests { let time = ::time::Timespec::new(1234567890, 54321); let utc = at_utc(time); - fail_unless!(utc.to_timespec() == time); - fail_unless!(utc.to_local().to_timespec() == time); + assert!(utc.to_timespec() == time); + assert!(utc.to_local().to_timespec() == time); } pub fn test_conversions() { @@ -982,12 +982,12 @@ mod tests { let utc = at_utc(time); let local = at(time); - fail_unless!(local.to_local() == local); - fail_unless!(local.to_utc() == utc); - fail_unless!(local.to_utc().to_local() == local); - fail_unless!(utc.to_utc() == utc); - fail_unless!(utc.to_local() == local); - fail_unless!(utc.to_local().to_utc() == utc); + assert!(local.to_local() == local); + assert!(local.to_utc() == utc); + assert!(local.to_utc().to_local() == local); + assert!(utc.to_utc() == utc); + assert!(utc.to_local() == local); + assert!(utc.to_local().to_utc() == utc); } pub fn test_strptime() { @@ -996,41 +996,41 @@ mod tests { match strptime(~"", ~"") { Ok(ref tm) => { - fail_unless!(tm.tm_sec == 0_i32); - fail_unless!(tm.tm_min == 0_i32); - fail_unless!(tm.tm_hour == 0_i32); - fail_unless!(tm.tm_mday == 0_i32); - fail_unless!(tm.tm_mon == 0_i32); - fail_unless!(tm.tm_year == 0_i32); - fail_unless!(tm.tm_wday == 0_i32); - fail_unless!(tm.tm_isdst== 0_i32); - fail_unless!(tm.tm_gmtoff == 0_i32); - fail_unless!(tm.tm_zone == ~""); - fail_unless!(tm.tm_nsec == 0_i32); + assert!(tm.tm_sec == 0_i32); + assert!(tm.tm_min == 0_i32); + assert!(tm.tm_hour == 0_i32); + assert!(tm.tm_mday == 0_i32); + assert!(tm.tm_mon == 0_i32); + assert!(tm.tm_year == 0_i32); + assert!(tm.tm_wday == 0_i32); + assert!(tm.tm_isdst== 0_i32); + assert!(tm.tm_gmtoff == 0_i32); + assert!(tm.tm_zone == ~""); + assert!(tm.tm_nsec == 0_i32); } Err(_) => () } let format = ~"%a %b %e %T %Y"; - fail_unless!(strptime(~"", format) == Err(~"Invalid time")); - fail_unless!(strptime(~"Fri Feb 13 15:31:30", format) + assert!(strptime(~"", format) == Err(~"Invalid time")); + assert!(strptime(~"Fri Feb 13 15:31:30", format) == Err(~"Invalid time")); match strptime(~"Fri Feb 13 15:31:30 2009", format) { Err(copy e) => fail!(e), Ok(ref tm) => { - fail_unless!(tm.tm_sec == 30_i32); - fail_unless!(tm.tm_min == 31_i32); - fail_unless!(tm.tm_hour == 15_i32); - fail_unless!(tm.tm_mday == 13_i32); - fail_unless!(tm.tm_mon == 1_i32); - fail_unless!(tm.tm_year == 109_i32); - fail_unless!(tm.tm_wday == 5_i32); - fail_unless!(tm.tm_yday == 0_i32); - fail_unless!(tm.tm_isdst == 0_i32); - fail_unless!(tm.tm_gmtoff == 0_i32); - fail_unless!(tm.tm_zone == ~""); - fail_unless!(tm.tm_nsec == 0_i32); + assert!(tm.tm_sec == 30_i32); + assert!(tm.tm_min == 31_i32); + assert!(tm.tm_hour == 15_i32); + assert!(tm.tm_mday == 13_i32); + assert!(tm.tm_mon == 1_i32); + assert!(tm.tm_year == 109_i32); + assert!(tm.tm_wday == 5_i32); + assert!(tm.tm_yday == 0_i32); + assert!(tm.tm_isdst == 0_i32); + assert!(tm.tm_gmtoff == 0_i32); + assert!(tm.tm_zone == ~""); + assert!(tm.tm_nsec == 0_i32); } } @@ -1050,7 +1050,7 @@ mod tests { ~"Friday", ~"Saturday" ]) |day| { - fail_unless!(test(*day, ~"%A")); + assert!(test(*day, ~"%A")); } for vec::each([ @@ -1062,7 +1062,7 @@ mod tests { ~"Fri", ~"Sat" ]) |day| { - fail_unless!(test(*day, ~"%a")); + assert!(test(*day, ~"%a")); } for vec::each([ @@ -1079,7 +1079,7 @@ mod tests { ~"November", ~"December" ]) |day| { - fail_unless!(test(*day, ~"%B")); + assert!(test(*day, ~"%B")); } for vec::each([ @@ -1096,56 +1096,56 @@ mod tests { ~"Nov", ~"Dec" ]) |day| { - fail_unless!(test(*day, ~"%b")); + assert!(test(*day, ~"%b")); } - fail_unless!(test(~"19", ~"%C")); - fail_unless!(test(~"Fri Feb 13 23:31:30 2009", ~"%c")); - fail_unless!(test(~"02/13/09", ~"%D")); - fail_unless!(test(~"03", ~"%d")); - fail_unless!(test(~"13", ~"%d")); - fail_unless!(test(~" 3", ~"%e")); - fail_unless!(test(~"13", ~"%e")); - fail_unless!(test(~"2009-02-13", ~"%F")); - fail_unless!(test(~"03", ~"%H")); - fail_unless!(test(~"13", ~"%H")); - fail_unless!(test(~"03", ~"%I")); // FIXME (#2350): flesh out - fail_unless!(test(~"11", ~"%I")); // FIXME (#2350): flesh out - fail_unless!(test(~"044", ~"%j")); - fail_unless!(test(~" 3", ~"%k")); - fail_unless!(test(~"13", ~"%k")); - fail_unless!(test(~" 1", ~"%l")); - fail_unless!(test(~"11", ~"%l")); - fail_unless!(test(~"03", ~"%M")); - fail_unless!(test(~"13", ~"%M")); - fail_unless!(test(~"\n", ~"%n")); - fail_unless!(test(~"am", ~"%P")); - fail_unless!(test(~"pm", ~"%P")); - fail_unless!(test(~"AM", ~"%p")); - fail_unless!(test(~"PM", ~"%p")); - fail_unless!(test(~"23:31", ~"%R")); - fail_unless!(test(~"11:31:30 AM", ~"%r")); - fail_unless!(test(~"11:31:30 PM", ~"%r")); - fail_unless!(test(~"03", ~"%S")); - fail_unless!(test(~"13", ~"%S")); - fail_unless!(test(~"15:31:30", ~"%T")); - fail_unless!(test(~"\t", ~"%t")); - fail_unless!(test(~"1", ~"%u")); - fail_unless!(test(~"7", ~"%u")); - fail_unless!(test(~"13-Feb-2009", ~"%v")); - fail_unless!(test(~"0", ~"%w")); - fail_unless!(test(~"6", ~"%w")); - fail_unless!(test(~"2009", ~"%Y")); - fail_unless!(test(~"09", ~"%y")); - fail_unless!(result::unwrap(strptime(~"UTC", ~"%Z")).tm_zone == + assert!(test(~"19", ~"%C")); + assert!(test(~"Fri Feb 13 23:31:30 2009", ~"%c")); + assert!(test(~"02/13/09", ~"%D")); + assert!(test(~"03", ~"%d")); + assert!(test(~"13", ~"%d")); + assert!(test(~" 3", ~"%e")); + assert!(test(~"13", ~"%e")); + assert!(test(~"2009-02-13", ~"%F")); + assert!(test(~"03", ~"%H")); + assert!(test(~"13", ~"%H")); + assert!(test(~"03", ~"%I")); // FIXME (#2350): flesh out + assert!(test(~"11", ~"%I")); // FIXME (#2350): flesh out + assert!(test(~"044", ~"%j")); + assert!(test(~" 3", ~"%k")); + assert!(test(~"13", ~"%k")); + assert!(test(~" 1", ~"%l")); + assert!(test(~"11", ~"%l")); + assert!(test(~"03", ~"%M")); + assert!(test(~"13", ~"%M")); + assert!(test(~"\n", ~"%n")); + assert!(test(~"am", ~"%P")); + assert!(test(~"pm", ~"%P")); + assert!(test(~"AM", ~"%p")); + assert!(test(~"PM", ~"%p")); + assert!(test(~"23:31", ~"%R")); + assert!(test(~"11:31:30 AM", ~"%r")); + assert!(test(~"11:31:30 PM", ~"%r")); + assert!(test(~"03", ~"%S")); + assert!(test(~"13", ~"%S")); + assert!(test(~"15:31:30", ~"%T")); + assert!(test(~"\t", ~"%t")); + assert!(test(~"1", ~"%u")); + assert!(test(~"7", ~"%u")); + assert!(test(~"13-Feb-2009", ~"%v")); + assert!(test(~"0", ~"%w")); + assert!(test(~"6", ~"%w")); + assert!(test(~"2009", ~"%Y")); + assert!(test(~"09", ~"%y")); + assert!(result::unwrap(strptime(~"UTC", ~"%Z")).tm_zone == ~"UTC"); - fail_unless!(result::unwrap(strptime(~"PST", ~"%Z")).tm_zone == + assert!(result::unwrap(strptime(~"PST", ~"%Z")).tm_zone == ~""); - fail_unless!(result::unwrap(strptime(~"-0000", ~"%z")).tm_gmtoff == + assert!(result::unwrap(strptime(~"-0000", ~"%z")).tm_gmtoff == 0); - fail_unless!(result::unwrap(strptime(~"-0800", ~"%z")).tm_gmtoff == + assert!(result::unwrap(strptime(~"-0800", ~"%z")).tm_gmtoff == 0); - fail_unless!(test(~"%", ~"%%")); + assert!(test(~"%", ~"%%")); } pub fn test_ctime() { @@ -1158,8 +1158,8 @@ mod tests { error!("test_ctime: %? %?", utc.ctime(), local.ctime()); - fail_unless!(utc.ctime() == ~"Fri Feb 13 23:31:30 2009"); - fail_unless!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); + assert!(utc.ctime() == ~"Fri Feb 13 23:31:30 2009"); + assert!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); } pub fn test_strftime() { @@ -1170,69 +1170,69 @@ mod tests { let utc = at_utc(time); let local = at(time); - fail_unless!(local.strftime(~"") == ~""); - fail_unless!(local.strftime(~"%A") == ~"Friday"); - fail_unless!(local.strftime(~"%a") == ~"Fri"); - fail_unless!(local.strftime(~"%B") == ~"February"); - fail_unless!(local.strftime(~"%b") == ~"Feb"); - fail_unless!(local.strftime(~"%C") == ~"20"); - fail_unless!(local.strftime(~"%c") == ~"Fri Feb 13 15:31:30 2009"); - fail_unless!(local.strftime(~"%D") == ~"02/13/09"); - fail_unless!(local.strftime(~"%d") == ~"13"); - fail_unless!(local.strftime(~"%e") == ~"13"); - fail_unless!(local.strftime(~"%F") == ~"2009-02-13"); - // fail_unless!(local.strftime("%G") == "2009"); - // fail_unless!(local.strftime("%g") == "09"); - fail_unless!(local.strftime(~"%H") == ~"15"); - fail_unless!(local.strftime(~"%I") == ~"03"); - fail_unless!(local.strftime(~"%j") == ~"044"); - fail_unless!(local.strftime(~"%k") == ~"15"); - fail_unless!(local.strftime(~"%l") == ~" 3"); - fail_unless!(local.strftime(~"%M") == ~"31"); - fail_unless!(local.strftime(~"%m") == ~"02"); - fail_unless!(local.strftime(~"%n") == ~"\n"); - fail_unless!(local.strftime(~"%P") == ~"pm"); - fail_unless!(local.strftime(~"%p") == ~"PM"); - fail_unless!(local.strftime(~"%R") == ~"15:31"); - fail_unless!(local.strftime(~"%r") == ~"03:31:30 PM"); - fail_unless!(local.strftime(~"%S") == ~"30"); - fail_unless!(local.strftime(~"%s") == ~"1234567890"); - fail_unless!(local.strftime(~"%T") == ~"15:31:30"); - fail_unless!(local.strftime(~"%t") == ~"\t"); - // fail_unless!(local.strftime("%U") == "06"); - fail_unless!(local.strftime(~"%u") == ~"5"); - // fail_unless!(local.strftime("%V") == "07"); - fail_unless!(local.strftime(~"%v") == ~"13-Feb-2009"); - // fail_unless!(local.strftime("%W") == "06"); - fail_unless!(local.strftime(~"%w") == ~"5"); + assert!(local.strftime(~"") == ~""); + assert!(local.strftime(~"%A") == ~"Friday"); + assert!(local.strftime(~"%a") == ~"Fri"); + assert!(local.strftime(~"%B") == ~"February"); + assert!(local.strftime(~"%b") == ~"Feb"); + assert!(local.strftime(~"%C") == ~"20"); + assert!(local.strftime(~"%c") == ~"Fri Feb 13 15:31:30 2009"); + assert!(local.strftime(~"%D") == ~"02/13/09"); + assert!(local.strftime(~"%d") == ~"13"); + assert!(local.strftime(~"%e") == ~"13"); + assert!(local.strftime(~"%F") == ~"2009-02-13"); + // assert!(local.strftime("%G") == "2009"); + // assert!(local.strftime("%g") == "09"); + assert!(local.strftime(~"%H") == ~"15"); + assert!(local.strftime(~"%I") == ~"03"); + assert!(local.strftime(~"%j") == ~"044"); + assert!(local.strftime(~"%k") == ~"15"); + assert!(local.strftime(~"%l") == ~" 3"); + assert!(local.strftime(~"%M") == ~"31"); + assert!(local.strftime(~"%m") == ~"02"); + assert!(local.strftime(~"%n") == ~"\n"); + assert!(local.strftime(~"%P") == ~"pm"); + assert!(local.strftime(~"%p") == ~"PM"); + assert!(local.strftime(~"%R") == ~"15:31"); + assert!(local.strftime(~"%r") == ~"03:31:30 PM"); + assert!(local.strftime(~"%S") == ~"30"); + assert!(local.strftime(~"%s") == ~"1234567890"); + assert!(local.strftime(~"%T") == ~"15:31:30"); + assert!(local.strftime(~"%t") == ~"\t"); + // assert!(local.strftime("%U") == "06"); + assert!(local.strftime(~"%u") == ~"5"); + // assert!(local.strftime("%V") == "07"); + assert!(local.strftime(~"%v") == ~"13-Feb-2009"); + // assert!(local.strftime("%W") == "06"); + assert!(local.strftime(~"%w") == ~"5"); // handle "%X" // handle "%x" - fail_unless!(local.strftime(~"%Y") == ~"2009"); - fail_unless!(local.strftime(~"%y") == ~"09"); + assert!(local.strftime(~"%Y") == ~"2009"); + assert!(local.strftime(~"%y") == ~"09"); // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = local.strftime(~"%Z"); - fail_unless!(zone == ~"PST" || zone == ~"Pacific Standard Time"); + assert!(zone == ~"PST" || zone == ~"Pacific Standard Time"); - fail_unless!(local.strftime(~"%z") == ~"-0800"); - fail_unless!(local.strftime(~"%%") == ~"%"); + assert!(local.strftime(~"%z") == ~"-0800"); + assert!(local.strftime(~"%%") == ~"%"); // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let rfc822 = local.rfc822(); let prefix = ~"Fri, 13 Feb 2009 15:31:30 "; - fail_unless!(rfc822 == prefix + ~"PST" || + assert!(rfc822 == prefix + ~"PST" || rfc822 == prefix + ~"Pacific Standard Time"); - fail_unless!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); - fail_unless!(local.rfc822z() == ~"Fri, 13 Feb 2009 15:31:30 -0800"); - fail_unless!(local.rfc3339() == ~"2009-02-13T15:31:30-08:00"); + assert!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); + assert!(local.rfc822z() == ~"Fri, 13 Feb 2009 15:31:30 -0800"); + assert!(local.rfc3339() == ~"2009-02-13T15:31:30-08:00"); - fail_unless!(utc.ctime() == ~"Fri Feb 13 23:31:30 2009"); - fail_unless!(utc.rfc822() == ~"Fri, 13 Feb 2009 23:31:30 GMT"); - fail_unless!(utc.rfc822z() == ~"Fri, 13 Feb 2009 23:31:30 -0000"); - fail_unless!(utc.rfc3339() == ~"2009-02-13T23:31:30Z"); + assert!(utc.ctime() == ~"Fri Feb 13 23:31:30 2009"); + assert!(utc.rfc822() == ~"Fri, 13 Feb 2009 23:31:30 GMT"); + assert!(utc.rfc822z() == ~"Fri, 13 Feb 2009 23:31:30 -0000"); + assert!(utc.rfc3339() == ~"2009-02-13T23:31:30Z"); } pub fn test_timespec_eq_ord() { @@ -1244,28 +1244,28 @@ mod tests { let d = &Timespec::new(2, 1); let e = &Timespec::new(2, 1); - fail_unless!(eq(d, e)); - fail_unless!(ne(c, e)); + assert!(eq(d, e)); + assert!(ne(c, e)); - fail_unless!(lt(a, b)); - fail_unless!(lt(b, c)); - fail_unless!(lt(c, d)); + assert!(lt(a, b)); + assert!(lt(b, c)); + assert!(lt(c, d)); - fail_unless!(le(a, b)); - fail_unless!(le(b, c)); - fail_unless!(le(c, d)); - fail_unless!(le(d, e)); - fail_unless!(le(e, d)); + assert!(le(a, b)); + assert!(le(b, c)); + assert!(le(c, d)); + assert!(le(d, e)); + assert!(le(e, d)); - fail_unless!(ge(b, a)); - fail_unless!(ge(c, b)); - fail_unless!(ge(d, c)); - fail_unless!(ge(e, d)); - fail_unless!(ge(d, e)); + assert!(ge(b, a)); + assert!(ge(c, b)); + assert!(ge(d, c)); + assert!(ge(e, d)); + assert!(ge(d, e)); - fail_unless!(gt(b, a)); - fail_unless!(gt(c, b)); - fail_unless!(gt(d, c)); + assert!(gt(b, a)); + assert!(gt(c, b)); + assert!(gt(d, c)); } #[test] diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index d72bfe73dd6..229d1a07caa 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -261,14 +261,14 @@ mod test { match recv_timeout(hl_loop, 10u, &test_po) { Some(val) => { - fail_unless!(val == expected); + assert!(val == expected); successes += 1; } _ => failures += 1 }; } - fail_unless!(successes > times / 2); + assert!(successes > times / 2); } #[test] @@ -292,6 +292,6 @@ mod test { }; } - fail_unless!(successes > times / 2); + assert!(successes > times / 2); } } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 9a184ca8682..d0868da4408 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -725,24 +725,24 @@ mod test_treemap { #[test] fn find_empty() { - let m = TreeMap::new::<int, int>(); fail_unless!(m.find(&5) == None); + let m = TreeMap::new::<int, int>(); assert!(m.find(&5) == None); } #[test] fn find_not_found() { let mut m = TreeMap::new(); - fail_unless!(m.insert(1, 2)); - fail_unless!(m.insert(5, 3)); - fail_unless!(m.insert(9, 3)); - fail_unless!(m.find(&2) == None); + assert!(m.insert(1, 2)); + assert!(m.insert(5, 3)); + assert!(m.insert(9, 3)); + assert!(m.find(&2) == None); } #[test] fn test_find_mut() { let mut m = TreeMap::new(); - fail_unless!(m.insert(1, 12)); - fail_unless!(m.insert(2, 8)); - fail_unless!(m.insert(5, 14)); + assert!(m.insert(1, 12)); + assert!(m.insert(2, 8)); + assert!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -753,24 +753,24 @@ mod test_treemap { #[test] fn insert_replace() { let mut m = TreeMap::new(); - fail_unless!(m.insert(5, 2)); - fail_unless!(m.insert(2, 9)); - fail_unless!(!m.insert(2, 11)); - fail_unless!(m.find(&2).unwrap() == &11); + assert!(m.insert(5, 2)); + assert!(m.insert(2, 9)); + assert!(!m.insert(2, 11)); + assert!(m.find(&2).unwrap() == &11); } #[test] fn test_clear() { let mut m = TreeMap::new(); m.clear(); - fail_unless!(m.insert(5, 11)); - fail_unless!(m.insert(12, -3)); - fail_unless!(m.insert(19, 2)); + assert!(m.insert(5, 11)); + assert!(m.insert(12, -3)); + assert!(m.insert(19, 2)); m.clear(); - fail_unless!(m.find(&5).is_none()); - fail_unless!(m.find(&12).is_none()); - fail_unless!(m.find(&19).is_none()); - fail_unless!(m.is_empty()); + assert!(m.find(&5).is_none()); + assert!(m.find(&12).is_none()); + assert!(m.find(&19).is_none()); + assert!(m.is_empty()); } #[test] @@ -785,28 +785,28 @@ mod test_treemap { m.insert(copy k1, copy v1); m.insert(copy k2, copy v2); - fail_unless!(m.find(&k2) == Some(&v2)); - fail_unless!(m.find(&k1) == Some(&v1)); + assert!(m.find(&k2) == Some(&v2)); + assert!(m.find(&k1) == Some(&v1)); } fn check_equal<K: Eq + TotalOrd, V: Eq>(ctrl: &[(K, V)], map: &TreeMap<K, V>) { - fail_unless!(ctrl.is_empty() == map.is_empty()); + assert!(ctrl.is_empty() == map.is_empty()); for ctrl.each |x| { let &(k, v) = x; - fail_unless!(map.find(&k).unwrap() == &v) + assert!(map.find(&k).unwrap() == &v) } for map.each |&(map_k, map_v)| { let mut found = false; for ctrl.each |x| { let &(ctrl_k, ctrl_v) = x; if *map_k == ctrl_k { - fail_unless!(*map_v == ctrl_v); + assert!(*map_v == ctrl_v); found = true; break; } } - fail_unless!(found); + assert!(found); } } @@ -814,12 +814,12 @@ mod test_treemap { parent: &~TreeNode<K, V>) { match *node { Some(ref r) => { - fail_unless!(r.key.cmp(&parent.key) == Less); - fail_unless!(r.level == parent.level - 1); // left is black + assert!(r.key.cmp(&parent.key) == Less); + assert!(r.level == parent.level - 1); // left is black check_left(&r.left, r); check_right(&r.right, r, false); } - None => fail_unless!(parent.level == 1) // parent is leaf + None => assert!(parent.level == 1) // parent is leaf } } @@ -828,15 +828,15 @@ mod test_treemap { parent_red: bool) { match *node { Some(ref r) => { - fail_unless!(r.key.cmp(&parent.key) == Greater); + assert!(r.key.cmp(&parent.key) == Greater); let red = r.level == parent.level; - if parent_red { fail_unless!(!red) } // no dual horizontal links + if parent_red { assert!(!red) } // no dual horizontal links // Right red or black - fail_unless!(red || r.level == parent.level - 1); + assert!(red || r.level == parent.level - 1); check_left(&r.left, r); check_right(&r.right, r, red); } - None => fail_unless!(parent.level == 1) // parent is leaf + None => assert!(parent.level == 1) // parent is leaf } } @@ -856,7 +856,7 @@ mod test_treemap { let mut ctrl = ~[]; check_equal(ctrl, &map); - fail_unless!(map.find(&5).is_none()); + assert!(map.find(&5).is_none()); let rng = rand::seeded_rng(&[42]); @@ -865,7 +865,7 @@ mod test_treemap { let k = rng.gen_int(); let v = rng.gen_int(); if !ctrl.contains(&(k, v)) { - fail_unless!(map.insert(k, v)); + assert!(map.insert(k, v)); ctrl.push((k, v)); check_structure(&map); check_equal(ctrl, &map); @@ -875,7 +875,7 @@ mod test_treemap { for 30.times { let r = rng.gen_uint_range(0, ctrl.len()); let (key, _) = vec::remove(&mut ctrl, r); - fail_unless!(map.remove(&key)); + assert!(map.remove(&key)); check_structure(&map); check_equal(ctrl, &map); } @@ -885,36 +885,36 @@ mod test_treemap { #[test] fn test_len() { let mut m = TreeMap::new(); - fail_unless!(m.insert(3, 6)); - fail_unless!(m.len() == 1); - fail_unless!(m.insert(0, 0)); - fail_unless!(m.len() == 2); - fail_unless!(m.insert(4, 8)); - fail_unless!(m.len() == 3); - fail_unless!(m.remove(&3)); - fail_unless!(m.len() == 2); - fail_unless!(!m.remove(&5)); - fail_unless!(m.len() == 2); - fail_unless!(m.insert(2, 4)); - fail_unless!(m.len() == 3); - fail_unless!(m.insert(1, 2)); - fail_unless!(m.len() == 4); + assert!(m.insert(3, 6)); + assert!(m.len() == 1); + assert!(m.insert(0, 0)); + assert!(m.len() == 2); + assert!(m.insert(4, 8)); + assert!(m.len() == 3); + assert!(m.remove(&3)); + assert!(m.len() == 2); + assert!(!m.remove(&5)); + assert!(m.len() == 2); + assert!(m.insert(2, 4)); + assert!(m.len() == 3); + assert!(m.insert(1, 2)); + assert!(m.len() == 4); } #[test] fn test_each() { let mut m = TreeMap::new(); - fail_unless!(m.insert(3, 6)); - fail_unless!(m.insert(0, 0)); - fail_unless!(m.insert(4, 8)); - fail_unless!(m.insert(2, 4)); - fail_unless!(m.insert(1, 2)); + assert!(m.insert(3, 6)); + assert!(m.insert(0, 0)); + assert!(m.insert(4, 8)); + assert!(m.insert(2, 4)); + assert!(m.insert(1, 2)); let mut n = 0; for m.each |&(k, v)| { - fail_unless!(*k == n); - fail_unless!(*v == n * 2); + assert!(*k == n); + assert!(*v == n * 2); n += 1; } } @@ -923,16 +923,16 @@ mod test_treemap { fn test_each_reverse() { let mut m = TreeMap::new(); - fail_unless!(m.insert(3, 6)); - fail_unless!(m.insert(0, 0)); - fail_unless!(m.insert(4, 8)); - fail_unless!(m.insert(2, 4)); - fail_unless!(m.insert(1, 2)); + assert!(m.insert(3, 6)); + assert!(m.insert(0, 0)); + assert!(m.insert(4, 8)); + assert!(m.insert(2, 4)); + assert!(m.insert(1, 2)); let mut n = 4; for m.each_reverse |&(k, v)| { - fail_unless!(*k == n); - fail_unless!(*v == n * 2); + assert!(*k == n); + assert!(*v == n * 2); n -= 1; } } @@ -942,17 +942,17 @@ mod test_treemap { let mut a = TreeMap::new(); let mut b = TreeMap::new(); - fail_unless!(a == b); - fail_unless!(a.insert(0, 5)); - fail_unless!(a != b); - fail_unless!(b.insert(0, 4)); - fail_unless!(a != b); - fail_unless!(a.insert(5, 19)); - fail_unless!(a != b); - fail_unless!(!b.insert(0, 5)); - fail_unless!(a != b); - fail_unless!(b.insert(5, 19)); - fail_unless!(a == b); + assert!(a == b); + assert!(a.insert(0, 5)); + assert!(a != b); + assert!(b.insert(0, 4)); + assert!(a != b); + assert!(a.insert(5, 19)); + assert!(a != b); + assert!(!b.insert(0, 5)); + assert!(a != b); + assert!(b.insert(5, 19)); + assert!(a == b); } #[test] @@ -960,17 +960,17 @@ mod test_treemap { let mut a = TreeMap::new(); let mut b = TreeMap::new(); - fail_unless!(!(a < b) && !(b < a)); - fail_unless!(b.insert(0, 5)); - fail_unless!(a < b); - fail_unless!(a.insert(0, 7)); - fail_unless!(!(a < b) && !(b < a)); - fail_unless!(b.insert(-2, 0)); - fail_unless!(b < a); - fail_unless!(a.insert(-5, 2)); - fail_unless!(a < b); - fail_unless!(a.insert(6, 2)); - fail_unless!(a < b && !(b < a)); + assert!(!(a < b) && !(b < a)); + assert!(b.insert(0, 5)); + assert!(a < b); + assert!(a.insert(0, 7)); + assert!(!(a < b) && !(b < a)); + assert!(b.insert(-2, 0)); + assert!(b < a); + assert!(a.insert(-5, 2)); + assert!(a < b); + assert!(a.insert(6, 2)); + assert!(a < b && !(b < a)); } #[test] @@ -978,13 +978,13 @@ mod test_treemap { let mut a = TreeMap::new(); let mut b = TreeMap::new(); - fail_unless!(a <= b && a >= b); - fail_unless!(a.insert(1, 1)); - fail_unless!(a > b && a >= b); - fail_unless!(b < a && b <= a); - fail_unless!(b.insert(2, 2)); - fail_unless!(b > a && b >= a); - fail_unless!(a < b && a <= b); + assert!(a <= b && a >= b); + assert!(a.insert(1, 1)); + assert!(a > b && a >= b); + assert!(b < a && b <= a); + assert!(b.insert(2, 2)); + assert!(b > a && b >= a); + assert!(a < b && a <= b); } #[test] @@ -996,22 +996,22 @@ mod test_treemap { let (x4, y4) = (29, 5); let (x5, y5) = (103, 3); - fail_unless!(m.insert(x1, y1)); - fail_unless!(m.insert(x2, y2)); - fail_unless!(m.insert(x3, y3)); - fail_unless!(m.insert(x4, y4)); - fail_unless!(m.insert(x5, y5)); + assert!(m.insert(x1, y1)); + assert!(m.insert(x2, y2)); + assert!(m.insert(x3, y3)); + assert!(m.insert(x4, y4)); + assert!(m.insert(x5, y5)); let m = m; let mut a = m.iter(); - fail_unless!(map_next(&mut a).unwrap() == (&x1, &y1)); - fail_unless!(map_next(&mut a).unwrap() == (&x2, &y2)); - fail_unless!(map_next(&mut a).unwrap() == (&x3, &y3)); - fail_unless!(map_next(&mut a).unwrap() == (&x4, &y4)); - fail_unless!(map_next(&mut a).unwrap() == (&x5, &y5)); + assert!(map_next(&mut a).unwrap() == (&x1, &y1)); + assert!(map_next(&mut a).unwrap() == (&x2, &y2)); + assert!(map_next(&mut a).unwrap() == (&x3, &y3)); + assert!(map_next(&mut a).unwrap() == (&x4, &y4)); + assert!(map_next(&mut a).unwrap() == (&x5, &y5)); - fail_unless!(map_next(&mut a).is_none()); + assert!(map_next(&mut a).is_none()); let mut b = m.iter(); @@ -1020,7 +1020,7 @@ mod test_treemap { let mut i = 0; for map_advance(&mut b) |x| { - fail_unless!(expected[i] == x); + assert!(expected[i] == x); i += 1; if i == 2 { @@ -1029,7 +1029,7 @@ mod test_treemap { } for map_advance(&mut b) |x| { - fail_unless!(expected[i] == x); + assert!(expected[i] == x); i += 1; } } @@ -1043,80 +1043,80 @@ mod test_set { fn test_clear() { let mut s = TreeSet::new(); s.clear(); - fail_unless!(s.insert(5)); - fail_unless!(s.insert(12)); - fail_unless!(s.insert(19)); + assert!(s.insert(5)); + assert!(s.insert(12)); + assert!(s.insert(19)); s.clear(); - fail_unless!(!s.contains(&5)); - fail_unless!(!s.contains(&12)); - fail_unless!(!s.contains(&19)); - fail_unless!(s.is_empty()); + assert!(!s.contains(&5)); + assert!(!s.contains(&12)); + assert!(!s.contains(&19)); + assert!(s.is_empty()); } #[test] fn test_disjoint() { let mut xs = TreeSet::new(); let mut ys = TreeSet::new(); - fail_unless!(xs.is_disjoint(&ys)); - fail_unless!(ys.is_disjoint(&xs)); - fail_unless!(xs.insert(5)); - fail_unless!(ys.insert(11)); - fail_unless!(xs.is_disjoint(&ys)); - fail_unless!(ys.is_disjoint(&xs)); - fail_unless!(xs.insert(7)); - fail_unless!(xs.insert(19)); - fail_unless!(xs.insert(4)); - fail_unless!(ys.insert(2)); - fail_unless!(ys.insert(-11)); - fail_unless!(xs.is_disjoint(&ys)); - fail_unless!(ys.is_disjoint(&xs)); - fail_unless!(ys.insert(7)); - fail_unless!(!xs.is_disjoint(&ys)); - fail_unless!(!ys.is_disjoint(&xs)); + assert!(xs.is_disjoint(&ys)); + assert!(ys.is_disjoint(&xs)); + assert!(xs.insert(5)); + assert!(ys.insert(11)); + assert!(xs.is_disjoint(&ys)); + assert!(ys.is_disjoint(&xs)); + assert!(xs.insert(7)); + assert!(xs.insert(19)); + assert!(xs.insert(4)); + assert!(ys.insert(2)); + assert!(ys.insert(-11)); + assert!(xs.is_disjoint(&ys)); + assert!(ys.is_disjoint(&xs)); + assert!(ys.insert(7)); + assert!(!xs.is_disjoint(&ys)); + assert!(!ys.is_disjoint(&xs)); } #[test] fn test_subset_and_superset() { let mut a = TreeSet::new(); - fail_unless!(a.insert(0)); - fail_unless!(a.insert(5)); - fail_unless!(a.insert(11)); - fail_unless!(a.insert(7)); + assert!(a.insert(0)); + assert!(a.insert(5)); + assert!(a.insert(11)); + assert!(a.insert(7)); let mut b = TreeSet::new(); - fail_unless!(b.insert(0)); - fail_unless!(b.insert(7)); - fail_unless!(b.insert(19)); - fail_unless!(b.insert(250)); - fail_unless!(b.insert(11)); - fail_unless!(b.insert(200)); + assert!(b.insert(0)); + assert!(b.insert(7)); + assert!(b.insert(19)); + assert!(b.insert(250)); + assert!(b.insert(11)); + assert!(b.insert(200)); - fail_unless!(!a.is_subset(&b)); - fail_unless!(!a.is_superset(&b)); - fail_unless!(!b.is_subset(&a)); - fail_unless!(!b.is_superset(&a)); + assert!(!a.is_subset(&b)); + assert!(!a.is_superset(&b)); + assert!(!b.is_subset(&a)); + assert!(!b.is_superset(&a)); - fail_unless!(b.insert(5)); + assert!(b.insert(5)); - fail_unless!(a.is_subset(&b)); - fail_unless!(!a.is_superset(&b)); - fail_unless!(!b.is_subset(&a)); - fail_unless!(b.is_superset(&a)); + assert!(a.is_subset(&b)); + assert!(!a.is_superset(&b)); + assert!(!b.is_subset(&a)); + assert!(b.is_superset(&a)); } #[test] fn test_each() { let mut m = TreeSet::new(); - fail_unless!(m.insert(3)); - fail_unless!(m.insert(0)); - fail_unless!(m.insert(4)); - fail_unless!(m.insert(2)); - fail_unless!(m.insert(1)); + assert!(m.insert(3)); + assert!(m.insert(0)); + assert!(m.insert(4)); + assert!(m.insert(2)); + assert!(m.insert(1)); let mut n = 0; for m.each |x| { - fail_unless!(*x == n); + assert!(*x == n); n += 1 } } @@ -1125,15 +1125,15 @@ mod test_set { fn test_each_reverse() { let mut m = TreeSet::new(); - fail_unless!(m.insert(3)); - fail_unless!(m.insert(0)); - fail_unless!(m.insert(4)); - fail_unless!(m.insert(2)); - fail_unless!(m.insert(1)); + assert!(m.insert(3)); + assert!(m.insert(0)); + assert!(m.insert(4)); + assert!(m.insert(2)); + assert!(m.insert(1)); let mut n = 4; for m.each_reverse |x| { - fail_unless!(*x == n); + assert!(*x == n); n -= 1 } } @@ -1143,15 +1143,15 @@ mod test_set { let mut set_a = TreeSet::new(); let mut set_b = TreeSet::new(); - for a.each |x| { fail_unless!(set_a.insert(*x)) } - for b.each |y| { fail_unless!(set_b.insert(*y)) } + for a.each |x| { assert!(set_a.insert(*x)) } + for b.each |y| { assert!(set_b.insert(*y)) } let mut i = 0; for f(&set_a, &set_b) |x| { - fail_unless!(*x == expected[i]); + assert!(*x == expected[i]); i += 1; } - fail_unless!(i == expected.len()); + assert!(i == expected.len()); } #[test] diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index 4fdd4e286da..77996de6d83 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -224,25 +224,25 @@ mod tests { #[test] fn test_is_digit() { - fail_unless!((unicode::icu::is_digit('0'))); - fail_unless!((!unicode::icu::is_digit('m'))); + assert!((unicode::icu::is_digit('0'))); + assert!((!unicode::icu::is_digit('m'))); } #[test] fn test_is_lower() { - fail_unless!((unicode::icu::is_lower('m'))); - fail_unless!((!unicode::icu::is_lower('M'))); + assert!((unicode::icu::is_lower('m'))); + assert!((!unicode::icu::is_lower('M'))); } #[test] fn test_is_space() { - fail_unless!((unicode::icu::is_space(' '))); - fail_unless!((!unicode::icu::is_space('m'))); + assert!((unicode::icu::is_space(' '))); + assert!((!unicode::icu::is_space('m'))); } #[test] fn test_is_upper() { - fail_unless!((unicode::icu::is_upper('M'))); - fail_unless!((!unicode::icu::is_upper('m'))); + assert!((unicode::icu::is_upper('M'))); + assert!((!unicode::icu::is_upper('m'))); } } diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 1c7a7c22a9d..fe40fc6a78b 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -188,7 +188,7 @@ extern fn tear_down_walk_cb(handle: *libc::c_void, arg: *libc::c_void) { // pretty much, if we still have an active handle and it is *not* // the async handle that facilities global loop communication, we // want to barf out and fail - fail_unless!(handle == arg); + assert!(handle == arg); } extern fn tear_down_close_cb(handle: *ll::uv_async_t) { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index f6cc35e0c9e..7582a7cff51 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -1339,7 +1339,7 @@ pub mod test { stream as *libc::c_void); let err_msg = get_last_err_info(test_loop); debug!(err_msg); - fail_unless!(false); + assert!(false); } debug!(~"finishing on_connect_cb"); } @@ -1411,12 +1411,12 @@ pub mod test { } else { debug!(~"tcp_connect() failure"); - fail_unless!(false); + assert!(false); } } else { debug!(~"tcp_init() failure"); - fail_unless!(false); + assert!(false); } loop_delete(test_loop); } @@ -1492,7 +1492,7 @@ pub mod test { debug!(get_last_err_info( get_loop_for_uv_handle(client_stream_ptr as *libc::c_void))); - fail_unless!(false); + assert!(false); } } else { @@ -1552,19 +1552,19 @@ pub mod test { else { debug!("server_connection_cb: bad read:%d", read_result as int); - fail_unless!(false); + assert!(false); } } else { debug!("server_connection_cb: bad accept: %d", accept_result as int); - fail_unless!(false); + assert!(false); } } else { debug!("server_connection_cb: bad client init: %d", client_init_result as int); - fail_unless!(false); + assert!(false); } } } @@ -1683,25 +1683,25 @@ pub mod test { else { debug!("uv_async_init failure: %d", async_result as int); - fail_unless!(false); + assert!(false); } } else { debug!("non-zero result on uv_listen: %d", listen_result as int); - fail_unless!(false); + assert!(false); } } else { debug!("non-zero result on uv_tcp_bind: %d", bind_result as int); - fail_unless!(false); + assert!(false); } } else { debug!("non-zero result on uv_tcp_init: %d", tcp_init_result as int); - fail_unless!(false); + assert!(false); } loop_delete(test_loop); } @@ -1749,8 +1749,8 @@ pub mod test { let msg_from_client = server_port.recv(); let msg_from_server = client_port.recv(); - fail_unless!(str::contains(msg_from_client, kill_server_msg)); - fail_unless!(str::contains(msg_from_server, server_resp_msg)); + assert!(str::contains(msg_from_client, kill_server_msg)); + assert!(str::contains(msg_from_server, server_resp_msg)); } } @@ -1794,7 +1794,7 @@ pub mod test { t_name, rust_size, foreign_size as uint); debug!(output); } - fail_unless!(sizes_match); + assert!(sizes_match); } } @@ -1859,7 +1859,7 @@ pub mod test { // .. can't get the uv::ll::sockaddr_in6 to == 28 :/ // .. so the type always appears to be 32 in size.. which is // good, i guess.. better too big than too little - fail_unless!((4u+foreign_handle_size as uint) == + assert!((4u+foreign_handle_size as uint) == rust_handle_size); } } @@ -1874,7 +1874,7 @@ pub mod test { foreign_handle_size as uint, rust_handle_size); debug!(output); // FIXME #1645 .. see note above about struct padding - fail_unless!((4u+foreign_handle_size as uint) == + assert!((4u+foreign_handle_size as uint) == rust_handle_size); } } |
