Skip to content

Assert #5627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Assert #5627

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn parse_config(args: ~[~str]) -> config {
getopts::optflag(~"jit"),
getopts::optflag(~"newrt")];

fail_unless!(!args.is_empty());
assert!(!args.is_empty());
let args_ = vec::tail(args);
let matches =
&match getopts::getopts(args_, opts) {
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
let mut env = os::env();

// Make sure we include the aux directory in the path
fail_unless!(prog.ends_with(~".exe"));
assert!(prog.ends_with(~".exe"));
let aux_path = prog.slice(0u, prog.len() - 4u) + ~".libaux";

env = do vec::map(env) |pair| {
Expand Down
26 changes: 13 additions & 13 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,30 +292,30 @@ pub fn test() {
}

assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
fail_unless!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
fail_unless!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
}

#[test]
pub fn append_test() {
fail_unless!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
}

#[test]
pub fn test_from_owned() {
fail_unless!(from_owned::<int>(~[]) == @[]);
fail_unless!(from_owned(~[true]) == @[true]);
fail_unless!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
fail_unless!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
fail_unless!(from_owned(~[~[42]]) == @[~[42]]);
assert!(from_owned::<int>(~[]) == @[]);
assert!(from_owned(~[true]) == @[true]);
assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
assert!(from_owned(~[~[42]]) == @[~[42]]);
}

#[test]
pub fn test_from_slice() {
fail_unless!(from_slice::<int>([]) == @[]);
fail_unless!(from_slice([true]) == @[true]);
fail_unless!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
fail_unless!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
fail_unless!(from_slice([@[42]]) == @[@[42]]);
assert!(from_slice::<int>([]) == @[]);
assert!(from_slice([true]) == @[true]);
assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
assert!(from_slice([@[42]]) == @[@[42]]);
}

8 changes: 4 additions & 4 deletions src/libcore/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ pub fn test_bool_from_str() {
use from_str::FromStr;

do all_values |v| {
fail_unless!(Some(v) == FromStr::from_str(to_str(v)))
assert!(Some(v) == FromStr::from_str(to_str(v)))
}
}

#[test]
pub fn test_bool_to_str() {
fail_unless!(to_str(false) == ~"false");
fail_unless!(to_str(true) == ~"true");
assert!(to_str(false) == ~"false");
assert!(to_str(true) == ~"true");
}

#[test]
pub fn test_bool_to_bit() {
do all_values |v| {
fail_unless!(to_bit(v) == if is_true(v) { 1u8 } else { 0u8 });
assert!(to_bit(v) == if is_true(v) { 1u8 } else { 0u8 });
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
*
* # Example
*
* fail_unless!(transmute("L") == ~[76u8, 0u8]);
* assert!(transmute("L") == ~[76u8, 0u8]);
*/
#[inline(always)]
pub unsafe fn transmute<L, G>(thing: L) -> G {
Expand Down Expand Up @@ -116,7 +116,7 @@ pub mod tests {

#[test]
pub fn test_reinterpret_cast() {
fail_unless!(1u == unsafe { reinterpret_cast(&1) });
assert!(1u == unsafe { reinterpret_cast(&1) });
}

#[test]
Expand All @@ -127,8 +127,8 @@ pub mod tests {
let ptr: *int = transmute(box); // refcount 2
let _box1: @~str = reinterpret_cast(&ptr);
let _box2: @~str = reinterpret_cast(&ptr);
fail_unless!(*_box1 == ~"box box box");
fail_unless!(*_box2 == ~"box box box");
assert!(*_box1 == ~"box box box");
assert!(*_box2 == ~"box box box");
// Will destroy _box1 and _box2. Without the bump, this would
// use-after-free. With too many bumps, it would leak.
}
Expand All @@ -140,15 +140,15 @@ pub mod tests {
unsafe {
let x = @100u8;
let x: *BoxRepr = transmute(x);
fail_unless!((*x).data == 100);
assert!((*x).data == 100);
let _x: @int = transmute(x);
}
}

#[test]
pub fn test_transmute2() {
unsafe {
fail_unless!(~[76u8, 0u8] == transmute(~"L"));
assert!(~[76u8, 0u8] == transmute(~"L"));
}
}
}
8 changes: 4 additions & 4 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ pub impl<T> Cell<T> {
#[test]
fn test_basic() {
let value_cell = Cell(~10);
fail_unless!(!value_cell.is_empty());
assert!(!value_cell.is_empty());
let value = value_cell.take();
fail_unless!(value == ~10);
fail_unless!(value_cell.is_empty());
assert!(value == ~10);
assert!(value_cell.is_empty());
value_cell.put_back(value);
fail_unless!(!value_cell.is_empty());
assert!(!value_cell.is_empty());
}

#[test]
Expand Down
56 changes: 28 additions & 28 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub fn escape_unicode(c: char) -> ~str {
let (c, pad) = (if c <= '\xff' { ('x', 2u) }
else if c <= '\uffff' { ('u', 4u) }
else { ('U', 8u) });
fail_unless!(str::len(s) <= pad);
assert!(str::len(s) <= pad);
let mut out = ~"\\";
unsafe {
str::push_str(&mut out, str::from_char(c));
Expand Down Expand Up @@ -258,32 +258,32 @@ impl Eq for char {

#[test]
fn test_is_lowercase() {
fail_unless!(is_lowercase('a'));
fail_unless!(is_lowercase('ö'));
fail_unless!(is_lowercase('ß'));
fail_unless!(!is_lowercase('Ü'));
fail_unless!(!is_lowercase('P'));
assert!(is_lowercase('a'));
assert!(is_lowercase('ö'));
assert!(is_lowercase('ß'));
assert!(!is_lowercase('Ü'));
assert!(!is_lowercase('P'));
}

#[test]
fn test_is_uppercase() {
fail_unless!(!is_uppercase('h'));
fail_unless!(!is_uppercase('ä'));
fail_unless!(!is_uppercase('ß'));
fail_unless!(is_uppercase('Ö'));
fail_unless!(is_uppercase('T'));
assert!(!is_uppercase('h'));
assert!(!is_uppercase('ä'));
assert!(!is_uppercase('ß'));
assert!(is_uppercase('Ö'));
assert!(is_uppercase('T'));
}

#[test]
fn test_is_whitespace() {
fail_unless!(is_whitespace(' '));
fail_unless!(is_whitespace('\u2007'));
fail_unless!(is_whitespace('\t'));
fail_unless!(is_whitespace('\n'));
assert!(is_whitespace(' '));
assert!(is_whitespace('\u2007'));
assert!(is_whitespace('\t'));
assert!(is_whitespace('\n'));

fail_unless!(!is_whitespace('a'));
fail_unless!(!is_whitespace('_'));
fail_unless!(!is_whitespace('\u0000'));
assert!(!is_whitespace('a'));
assert!(!is_whitespace('_'));
assert!(!is_whitespace('\u0000'));
}

#[test]
Expand All @@ -299,24 +299,24 @@ fn test_to_digit() {
assert_eq!(to_digit('z', 36u), Some(35u));
assert_eq!(to_digit('Z', 36u), Some(35u));

fail_unless!(to_digit(' ', 10u).is_none());
fail_unless!(to_digit('$', 36u).is_none());
assert!(to_digit(' ', 10u).is_none());
assert!(to_digit('$', 36u).is_none());
}

#[test]
fn test_is_ascii() {
fail_unless!(str::all(~"banana", is_ascii));
fail_unless!(! str::all(~"ประเทศไทย中华Việt Nam", is_ascii));
assert!(str::all(~"banana", is_ascii));
assert!(! str::all(~"ประเทศไทย中华Việt Nam", is_ascii));
}

#[test]
fn test_is_digit() {
fail_unless!(is_digit('2'));
fail_unless!(is_digit('7'));
fail_unless!(! is_digit('c'));
fail_unless!(! is_digit('i'));
fail_unless!(! is_digit('z'));
fail_unless!(! is_digit('Q'));
assert!(is_digit('2'));
assert!(is_digit('7'));
assert!(! is_digit('c'));
assert!(! is_digit('i'));
assert!(! is_digit('z'));
assert!(! is_digit('Q'));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ mod test {

#[test]
fn test_int_totaleq() {
fail_unless!(5.equals(&5));
fail_unless!(!2.equals(&17));
assert!(5.equals(&5));
assert!(!2.equals(&17));
}
}
2 changes: 1 addition & 1 deletion src/libcore/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,6 @@ pub mod test {
let _chan = chan;
}

fail_unless!(!port.peek());
assert!(!port.peek());
}
}
10 changes: 5 additions & 5 deletions src/libcore/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod test {
trouble(1);
}

fail_unless!(inner_trapped);
assert!(inner_trapped);
}

#[test]
Expand All @@ -143,7 +143,7 @@ mod test {
trouble(1);
}

fail_unless!(outer_trapped);
assert!(outer_trapped);
}

fn nested_reraise_trap_test_inner() {
Expand All @@ -160,7 +160,7 @@ mod test {
trouble(1);
}

fail_unless!(inner_trapped);
assert!(inner_trapped);
}

#[test]
Expand All @@ -175,7 +175,7 @@ mod test {
nested_reraise_trap_test_inner();
}

fail_unless!(outer_trapped);
assert!(outer_trapped);
}

#[test]
Expand All @@ -190,6 +190,6 @@ mod test {
trouble(1);
}

fail_unless!(trapped);
assert!(trapped);
}
}
Loading