Skip to content

Commit d661711

Browse files
committed
test: Fix tests.
1 parent 9a17ef9 commit d661711

File tree

104 files changed

+397
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+397
-272
lines changed

src/libcore/core.rc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ Implicitly, all crates behave as if they included the following prologue:
5252
#[deny(non_camel_case_types)];
5353
#[allow(deprecated_mutable_fields)];
5454

55+
// On Linux, link to the runtime with -lrt.
56+
#[cfg(target_os = "linux")]
57+
pub mod linkhack {
58+
#[link_args="-lrustrt -lrt"]
59+
extern {
60+
}
61+
}
62+
5563
/* The Prelude. */
5664

5765
pub mod prelude;

src/libcore/num/int-template.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,22 @@ fn test_parse_bytes() {
298298
fail_unless!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T));
299299
fail_unless!(parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T));
300300
fail_unless!(i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32));
301-
fail_unless!(i32::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as i32));
302-
fail_unless!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as i32));
301+
fail_unless!(i32::parse_bytes(to_bytes(~"ffff"), 16u) ==
302+
Some(65535 as i32));
303+
fail_unless!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) ==
304+
Some(65535 as i32));
303305
fail_unless!(parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T));
304306
fail_unless!(parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T));
305307
306308
fail_unless!(parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T));
307309
fail_unless!(parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T));
308310
fail_unless!(parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T));
309-
fail_unless!(i32::parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as i32));
310-
fail_unless!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as i32));
311-
fail_unless!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as i32));
311+
fail_unless!(i32::parse_bytes(to_bytes(~"-123"), 16u) ==
312+
Some(-291 as i32));
313+
fail_unless!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) ==
314+
Some(-65535 as i32));
315+
fail_unless!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) ==
316+
Some(-65535 as i32));
312317
fail_unless!(parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T));
313318
fail_unless!(parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T));
314319

src/libcore/num/uint-template.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,10 @@ pub fn test_parse_bytes() {
266266
fail_unless!(parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T));
267267
fail_unless!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T));
268268
fail_unless!(parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T));
269-
fail_unless!(u16::parse_bytes(to_bytes(~"123"), 16u) == Some(291u as u16));
270-
fail_unless!(u16::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as u16));
269+
fail_unless!(u16::parse_bytes(to_bytes(~"123"), 16u) ==
270+
Some(291u as u16));
271+
fail_unless!(u16::parse_bytes(to_bytes(~"ffff"), 16u) ==
272+
Some(65535u as u16));
271273
fail_unless!(parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T));
272274
273275
fail_unless!(parse_bytes(to_bytes(~"Z"), 10u).is_none());

src/libcore/os.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ pub fn waitpid(pid: pid_t) -> c_int {
313313
use libc::funcs::posix01::wait::*;
314314
let mut status = 0 as c_int;
315315

316-
fail_unless!((waitpid(pid, &mut status, 0 as c_int) != (-1 as c_int)));
316+
fail_unless!((waitpid(pid, &mut status, 0 as c_int) !=
317+
(-1 as c_int)));
317318
return status;
318319
}
319320
}
@@ -1309,7 +1310,8 @@ mod tests {
13091310
#[test]
13101311
fn path_exists() {
13111312
fail_unless!((os::path_exists(&Path("."))));
1312-
fail_unless!((!os::path_exists(&Path("test/nonexistent-bogus-path"))));
1313+
fail_unless!((!os::path_exists(&Path(
1314+
"test/nonexistent-bogus-path"))));
13131315
}
13141316
13151317
#[test]

src/libcore/ptr.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,12 @@ pub fn test() {
328328
fail_unless!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16));
329329
copy_memory(vec::raw::to_mut_ptr(v1),
330330
offset(vec::raw::to_ptr(v0), 2u), 1u);
331-
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16));
331+
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
332+
v1[2] == 0u16));
332333
copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u),
333334
vec::raw::to_ptr(v0), 1u);
334-
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16));
335+
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
336+
v1[2] == 32000u16));
335337
}
336338
}
337339

@@ -342,9 +344,12 @@ pub fn test_position() {
342344

343345
let s = ~"hello";
344346
unsafe {
345-
fail_unless!(2u == as_c_str(s, |p| position(p, |c| *c == 'l' as c_char)));
346-
fail_unless!(4u == as_c_str(s, |p| position(p, |c| *c == 'o' as c_char)));
347-
fail_unless!(5u == as_c_str(s, |p| position(p, |c| *c == 0 as c_char)));
347+
fail_unless!(2u == as_c_str(s, |p| position(p,
348+
|c| *c == 'l' as c_char)));
349+
fail_unless!(4u == as_c_str(s, |p| position(p,
350+
|c| *c == 'o' as c_char)));
351+
fail_unless!(5u == as_c_str(s, |p| position(p,
352+
|c| *c == 0 as c_char)));
348353
}
349354
}
350355

src/libcore/str.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,9 +2807,10 @@ mod tests {
28072807
#[test]
28082808
fn test_to_lower() {
28092809
unsafe {
2810-
fail_unless!(~"" == map(~"", |c| libc::tolower(c as c_char) as char));
2810+
fail_unless!(~"" == map(~"",
2811+
|c| libc::tolower(c as c_char) as char));
28112812
fail_unless!(~"ymca" == map(~"YMCA",
2812-
|c| libc::tolower(c as c_char) as char));
2813+
|c| libc::tolower(c as c_char) as char));
28132814
}
28142815
}
28152816
@@ -2867,7 +2868,8 @@ mod tests {
28672868
fail_unless!(replace(~"a", a, ~"b") == ~"b");
28682869
fail_unless!(replace(~"ab", a, ~"b") == ~"bb");
28692870
let test = ~"test";
2870-
fail_unless!(replace(~" test test ", test, ~"toast") == ~" toast toast ");
2871+
fail_unless!(replace(~" test test ", test, ~"toast") ==
2872+
~" toast toast ");
28712873
fail_unless!(replace(~" test test ", test, ~"") == ~" ");
28722874
}
28732875
@@ -2977,18 +2979,24 @@ mod tests {
29772979
29782980
#[test]
29792981
fn test_trim_left_chars() {
2980-
fail_unless!(trim_left_chars(~" *** foo *** ", ~[]) == ~" *** foo *** ");
2981-
fail_unless!(trim_left_chars(~" *** foo *** ", ~['*', ' ']) == ~"foo *** ");
2982+
fail_unless!(trim_left_chars(~" *** foo *** ", ~[]) ==
2983+
~" *** foo *** ");
2984+
fail_unless!(trim_left_chars(~" *** foo *** ", ~['*', ' ']) ==
2985+
~"foo *** ");
29822986
fail_unless!(trim_left_chars(~" *** *** ", ~['*', ' ']) == ~"");
2983-
fail_unless!(trim_left_chars(~"foo *** ", ~['*', ' ']) == ~"foo *** ");
2987+
fail_unless!(trim_left_chars(~"foo *** ", ~['*', ' ']) ==
2988+
~"foo *** ");
29842989
}
29852990
29862991
#[test]
29872992
fn test_trim_right_chars() {
2988-
fail_unless!(trim_right_chars(~" *** foo *** ", ~[]) == ~" *** foo *** ");
2989-
fail_unless!(trim_right_chars(~" *** foo *** ", ~['*', ' ']) == ~" *** foo");
2993+
fail_unless!(trim_right_chars(~" *** foo *** ", ~[]) ==
2994+
~" *** foo *** ");
2995+
fail_unless!(trim_right_chars(~" *** foo *** ", ~['*', ' ']) ==
2996+
~" *** foo");
29902997
fail_unless!(trim_right_chars(~" *** *** ", ~['*', ' ']) == ~"");
2991-
fail_unless!(trim_right_chars(~" *** foo", ~['*', ' ']) == ~" *** foo");
2998+
fail_unless!(trim_right_chars(~" *** foo", ~['*', ' ']) ==
2999+
~" *** foo");
29923000
}
29933001
29943002
#[test]
@@ -3321,7 +3329,8 @@ mod tests {
33213329
#[test]
33223330
fn test_map() {
33233331
unsafe {
3324-
fail_unless!(~"" == map(~"", |c| libc::toupper(c as c_char) as char));
3332+
fail_unless!(~"" == map(~"", |c|
3333+
libc::toupper(c as c_char) as char));
33253334
fail_unless!(~"YMCA" == map(~"ymca",
33263335
|c| libc::toupper(c as c_char) as char));
33273336
}

src/libcore/task/local_data.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ fn test_tls_multitask() {
9494
// TLS shouldn't carry over.
9595
fail_unless!(local_data_get(my_key).is_none());
9696
local_data_set(my_key, @~"child data");
97-
fail_unless!(*(local_data_get(my_key).get()) == ~"child data");
97+
fail_unless!(*(local_data_get(my_key).get()) ==
98+
~"child data");
9899
// should be cleaned up for us
99100
}
100101
}

src/libcore/task/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,8 @@ fn test_spawn_sched_childs_on_default_sched() {
940940

941941
#[cfg(test)]
942942
pub mod testrt {
943+
use libc;
944+
943945
#[nolink]
944946
pub extern {
945947
unsafe fn rust_dbg_lock_create() -> *libc::c_void;

src/libcore/vec.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,7 +3409,8 @@ mod tests {
34093409
fail_unless!(rsplit(~[], f) == ~[]);
34103410
fail_unless!(rsplit(~[1, 2], f) == ~[~[1, 2]]);
34113411
fail_unless!(rsplit(~[1, 2, 3], f) == ~[~[1, 2], ~[]]);
3412-
fail_unless!(rsplit(~[1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]);
3412+
fail_unless!(rsplit(~[1, 2, 3, 4, 3, 5], f) ==
3413+
~[~[1, 2], ~[4], ~[5]]);
34133414
}
34143415

34153416
#[test]
@@ -3427,9 +3428,12 @@ mod tests {
34273428
fn test_partition() {
34283429
// FIXME (#4355 maybe): using v.partition here crashes
34293430
fail_unless!(partition(~[], |x: &int| *x < 3) == (~[], ~[]));
3430-
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 4) == (~[1, 2, 3], ~[]));
3431-
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 2) == (~[1], ~[2, 3]));
3432-
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 0) == (~[], ~[1, 2, 3]));
3431+
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 4) ==
3432+
(~[1, 2, 3], ~[]));
3433+
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 2) ==
3434+
(~[1], ~[2, 3]));
3435+
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 0) ==
3436+
(~[], ~[1, 2, 3]));
34333437
}
34343438

34353439
#[test]

src/librustc/middle/trans/callee.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ pub fn trans_arg_expr(bcx: block,
704704
// FIXME(#3548) use the adjustments table
705705
match autoref_arg {
706706
DoAutorefArg => {
707-
fail_unless!(!bcx.ccx().maps.moves_map.contains_key(&arg_expr.id));
707+
fail_unless!(!
708+
bcx.ccx().maps.moves_map.contains_key(&arg_expr.id));
708709
val = arg_datum.to_ref_llval(bcx);
709710
}
710711
DontAutorefArg => {

0 commit comments

Comments
 (0)