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 => {

src/librustdoc/desc_to_brief_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ fn should_promote_desc() {
9090
#[test]
9191
fn should_promote_trait_method_desc() {
9292
let doc = test::mk_doc(~"trait i { #[doc = \"desc\"] fn a(); }");
93-
fail_unless!(doc.cratemod().traits()[0].methods[0].brief == Some(~"desc"));
93+
fail_unless!(doc.cratemod().traits()[0].methods[0].brief ==
94+
Some(~"desc"));
9495
}
9596
9697
#[test]

src/librustdoc/extract.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ mod test {
380380
#[test]
381381
pub fn extract_mods_deep() {
382382
let doc = mk_doc(~"mod a { mod b { mod c { } } }");
383-
fail_unless!(doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c");
383+
fail_unless!(doc.cratemod().mods()[0].mods()[0].mods()[0].name() ==
384+
~"c");
384385
}
385386
386387
#[test]

src/librustdoc/markdown_index_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ fn pandoc_header_id(header: &str) -> ~str {
160160

161161
#[test]
162162
fn should_remove_punctuation_from_headers() {
163-
fail_unless!(pandoc_header_id(~"impl foo of bar<A>") == ~"impl-foo-of-bara");
163+
fail_unless!(pandoc_header_id(~"impl foo of bar<A>") ==
164+
~"impl-foo-of-bara");
164165
fail_unless!(pandoc_header_id(~"impl of num::num for int")
165166
== ~"impl-of-numnum-for-int");
166167
fail_unless!(pandoc_header_id(~"impl of num::num for int/&")

src/librustdoc/markdown_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ fn should_write_impl_header() {
752752
#[test]
753753
fn should_write_impl_header_with_trait() {
754754
let markdown = test::render(~"impl j for int { fn a() { } }");
755-
fail_unless!(str::contains(markdown, ~"## Implementation of `j` for `int`"));
755+
fail_unless!(str::contains(markdown,
756+
~"## Implementation of `j` for `int`"));
756757
}
757758

758759
#[test]

src/librustdoc/text_pass.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ fn should_execute_on_trait_method_section_bodies() {
265265
# Header\n\
266266
Body \"]\
267267
fn a(); }");
268-
fail_unless!(doc.cratemod().traits()[0].methods[0].sections[0].body == ~"Body");
268+
fail_unless!(doc.cratemod().traits()[0].methods[0].sections[0].body ==
269+
~"Body");
269270
}
270271
271272
#[test]
@@ -288,7 +289,8 @@ fn should_execute_on_impl_method_section_bodies() {
288289
# Header\n\
289290
Body \"]\
290291
fn a() { } }");
291-
fail_unless!(doc.cratemod().impls()[0].methods[0].sections[0].body == ~"Body");
292+
fail_unless!(doc.cratemod().impls()[0].methods[0].sections[0].body ==
293+
~"Body");
292294
}
293295
294296
#[cfg(test)]

src/librustdoc/tystr_pass.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ fn should_add_fn_sig() {
9292
#[test]
9393
fn should_add_foreign_fn_sig() {
9494
let doc = test::mk_doc(~"extern mod a { fn a<T>() -> int; }");
95-
fail_unless!(doc.cratemod().nmods()[0].fns[0].sig == Some(~"fn a<T>() -> int"));
95+
fail_unless!(doc.cratemod().nmods()[0].fns[0].sig ==
96+
Some(~"fn a<T>() -> int"));
9697
}
9798
9899
fn fold_const(
@@ -165,7 +166,8 @@ fn fold_enum(
165166
#[test]
166167
fn should_add_variant_sigs() {
167168
let doc = test::mk_doc(~"enum a { b(int) }");
168-
fail_unless!(doc.cratemod().enums()[0].variants[0].sig == Some(~"b(int)"));
169+
fail_unless!(doc.cratemod().enums()[0].variants[0].sig ==
170+
Some(~"b(int)"));
169171
}
170172
171173
fn fold_trait(
@@ -407,7 +409,8 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
407409
#[test]
408410
fn should_add_struct_defs() {
409411
let doc = test::mk_doc(~"struct S { field: () }");
410-
fail_unless!((&doc.cratemod().structs()[0].sig).get().contains("struct S {"));
412+
fail_unless!((&doc.cratemod().structs()[0].sig).get().contains(
413+
"struct S {"));
411414
}
412415
413416
#[test]

src/libstd/arc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ mod tests {
519519
let _ = p.recv();
520520
do arc2.access_cond |one, cond| {
521521
cond.signal();
522-
fail_unless!(*one == 0); // Parent should fail when it wakes up.
522+
// Parent should fail when it wakes up.
523+
fail_unless!(*one == 0);
523524
}
524525
}
525526

src/libstd/bitv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,8 @@ mod tests {
12381238
12391239
#[test]
12401240
pub fn test_from_bools() {
1241-
fail_unless!(from_bools([true, false, true, true]).to_str() == ~"1011");
1241+
fail_unless!(from_bools([true, false, true, true]).to_str() ==
1242+
~"1011");
12421243
}
12431244
12441245
#[test]

src/libstd/md4.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ fn test_md4() {
128128
fail_unless!(md4_text(~"") == ~"31d6cfe0d16ae931b73c59d7e0c089c0");
129129
fail_unless!(md4_text(~"a") == ~"bde52cb31de33e46245e05fbdbd6fb24");
130130
fail_unless!(md4_text(~"abc") == ~"a448017aaf21d8525fc10ae87aa6729d");
131-
fail_unless!(md4_text(~"message digest") == ~"d9130a8164549fe818874806e1c7014b");
131+
fail_unless!(md4_text(~"message digest") ==
132+
~"d9130a8164549fe818874806e1c7014b");
132133
fail_unless!(md4_text(~"abcdefghijklmnopqrstuvwxyz") ==
133134
~"d79e1c308aa5bbcdeea8ed63df412da9");
134135
fail_unless!(md4_text(

src/libstd/net_url.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,8 @@ mod tests {
971971
fail_unless!(encode_component("") == ~"");
972972
fail_unless!(encode_component("http://example.com") ==
973973
~"http%3A%2F%2Fexample.com");
974-
fail_unless!(encode_component("foo bar% baz") == ~"foo%20bar%25%20baz");
974+
fail_unless!(encode_component("foo bar% baz") ==
975+
~"foo%20bar%25%20baz");
975976
fail_unless!(encode_component(" ") == ~"%20");
976977
fail_unless!(encode_component("!") == ~"%21");
977978
fail_unless!(encode_component("#") == ~"%23");
@@ -1065,7 +1066,8 @@ mod tests {
10651066
10661067
let mut m = LinearMap::new();
10671068
m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]);
1068-
fail_unless!(encode_form_urlencoded(&m) == ~"foo+bar=abc&foo+bar=12+%3D+34");
1069+
fail_unless!(encode_form_urlencoded(&m) ==
1070+
~"foo+bar=abc&foo+bar=12+%3D+34");
10691071
}
10701072
10711073
#[test]

src/libstd/test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ mod tests {
962962

963963
for vec::each(pairs) |p| {
964964
match *p {
965-
(ref a, ref b) => { fail_unless!((*a == b.desc.name.to_str())); }
965+
(ref a, ref b) => {
966+
fail_unless!((*a == b.desc.name.to_str()));
967+
}
966968
}
967969
}
968970
}

0 commit comments

Comments
 (0)