test: Fix tests.

This commit is contained in:
Patrick Walton 2013-03-06 19:09:17 -08:00
parent 9a17ef9b52
commit d661711cc2
104 changed files with 398 additions and 273 deletions

View File

@ -52,6 +52,14 @@ Implicitly, all crates behave as if they included the following prologue:
#[deny(non_camel_case_types)];
#[allow(deprecated_mutable_fields)];
// On Linux, link to the runtime with -lrt.
#[cfg(target_os = "linux")]
pub mod linkhack {
#[link_args="-lrustrt -lrt"]
extern {
}
}
/* The Prelude. */
pub mod prelude;

View File

@ -298,17 +298,22 @@ fn test_parse_bytes() {
fail_unless!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T));
fail_unless!(parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T));
fail_unless!(i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"ffff"), 16u) ==
Some(65535 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) ==
Some(65535 as i32));
fail_unless!(parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T));
fail_unless!(parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T));
fail_unless!(parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T));
fail_unless!(parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T));
fail_unless!(parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T));
fail_unless!(i32::parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"-123"), 16u) ==
Some(-291 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) ==
Some(-65535 as i32));
fail_unless!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) ==
Some(-65535 as i32));
fail_unless!(parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T));
fail_unless!(parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T));

View File

@ -266,8 +266,10 @@ pub fn test_parse_bytes() {
fail_unless!(parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T));
fail_unless!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T));
fail_unless!(parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T));
fail_unless!(u16::parse_bytes(to_bytes(~"123"), 16u) == Some(291u as u16));
fail_unless!(u16::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as u16));
fail_unless!(u16::parse_bytes(to_bytes(~"123"), 16u) ==
Some(291u as u16));
fail_unless!(u16::parse_bytes(to_bytes(~"ffff"), 16u) ==
Some(65535u as u16));
fail_unless!(parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T));
fail_unless!(parse_bytes(to_bytes(~"Z"), 10u).is_none());

View File

@ -313,7 +313,8 @@ pub fn waitpid(pid: pid_t) -> c_int {
use libc::funcs::posix01::wait::*;
let mut status = 0 as c_int;
fail_unless!((waitpid(pid, &mut status, 0 as c_int) != (-1 as c_int)));
fail_unless!((waitpid(pid, &mut status, 0 as c_int) !=
(-1 as c_int)));
return status;
}
}
@ -1309,7 +1310,8 @@ mod tests {
#[test]
fn path_exists() {
fail_unless!((os::path_exists(&Path("."))));
fail_unless!((!os::path_exists(&Path("test/nonexistent-bogus-path"))));
fail_unless!((!os::path_exists(&Path(
"test/nonexistent-bogus-path"))));
}
#[test]

View File

@ -328,10 +328,12 @@ pub fn test() {
fail_unless!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16));
copy_memory(vec::raw::to_mut_ptr(v1),
offset(vec::raw::to_ptr(v0), 2u), 1u);
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16));
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
v1[2] == 0u16));
copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u),
vec::raw::to_ptr(v0), 1u);
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16));
fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
v1[2] == 32000u16));
}
}
@ -342,9 +344,12 @@ pub fn test_position() {
let s = ~"hello";
unsafe {
fail_unless!(2u == as_c_str(s, |p| position(p, |c| *c == 'l' as c_char)));
fail_unless!(4u == as_c_str(s, |p| position(p, |c| *c == 'o' as c_char)));
fail_unless!(5u == as_c_str(s, |p| position(p, |c| *c == 0 as c_char)));
fail_unless!(2u == as_c_str(s, |p| position(p,
|c| *c == 'l' as c_char)));
fail_unless!(4u == as_c_str(s, |p| position(p,
|c| *c == 'o' as c_char)));
fail_unless!(5u == as_c_str(s, |p| position(p,
|c| *c == 0 as c_char)));
}
}

View File

@ -2807,9 +2807,10 @@ mod tests {
#[test]
fn test_to_lower() {
unsafe {
fail_unless!(~"" == map(~"", |c| libc::tolower(c as c_char) as char));
fail_unless!(~"" == map(~"",
|c| libc::tolower(c as c_char) as char));
fail_unless!(~"ymca" == map(~"YMCA",
|c| libc::tolower(c as c_char) as char));
|c| libc::tolower(c as c_char) as char));
}
}
@ -2867,7 +2868,8 @@ mod tests {
fail_unless!(replace(~"a", a, ~"b") == ~"b");
fail_unless!(replace(~"ab", a, ~"b") == ~"bb");
let test = ~"test";
fail_unless!(replace(~" test test ", test, ~"toast") == ~" toast toast ");
fail_unless!(replace(~" test test ", test, ~"toast") ==
~" toast toast ");
fail_unless!(replace(~" test test ", test, ~"") == ~" ");
}
@ -2977,18 +2979,24 @@ mod tests {
#[test]
fn test_trim_left_chars() {
fail_unless!(trim_left_chars(~" *** foo *** ", ~[]) == ~" *** foo *** ");
fail_unless!(trim_left_chars(~" *** foo *** ", ~['*', ' ']) == ~"foo *** ");
fail_unless!(trim_left_chars(~" *** foo *** ", ~[]) ==
~" *** foo *** ");
fail_unless!(trim_left_chars(~" *** foo *** ", ~['*', ' ']) ==
~"foo *** ");
fail_unless!(trim_left_chars(~" *** *** ", ~['*', ' ']) == ~"");
fail_unless!(trim_left_chars(~"foo *** ", ~['*', ' ']) == ~"foo *** ");
fail_unless!(trim_left_chars(~"foo *** ", ~['*', ' ']) ==
~"foo *** ");
}
#[test]
fn test_trim_right_chars() {
fail_unless!(trim_right_chars(~" *** foo *** ", ~[]) == ~" *** foo *** ");
fail_unless!(trim_right_chars(~" *** foo *** ", ~['*', ' ']) == ~" *** foo");
fail_unless!(trim_right_chars(~" *** foo *** ", ~[]) ==
~" *** foo *** ");
fail_unless!(trim_right_chars(~" *** foo *** ", ~['*', ' ']) ==
~" *** foo");
fail_unless!(trim_right_chars(~" *** *** ", ~['*', ' ']) == ~"");
fail_unless!(trim_right_chars(~" *** foo", ~['*', ' ']) == ~" *** foo");
fail_unless!(trim_right_chars(~" *** foo", ~['*', ' ']) ==
~" *** foo");
}
#[test]
@ -3321,7 +3329,8 @@ mod tests {
#[test]
fn test_map() {
unsafe {
fail_unless!(~"" == map(~"", |c| libc::toupper(c as c_char) as char));
fail_unless!(~"" == map(~"", |c|
libc::toupper(c as c_char) as char));
fail_unless!(~"YMCA" == map(~"ymca",
|c| libc::toupper(c as c_char) as char));
}

View File

@ -94,7 +94,8 @@ fn test_tls_multitask() {
// TLS shouldn't carry over.
fail_unless!(local_data_get(my_key).is_none());
local_data_set(my_key, @~"child data");
fail_unless!(*(local_data_get(my_key).get()) == ~"child data");
fail_unless!(*(local_data_get(my_key).get()) ==
~"child data");
// should be cleaned up for us
}
}

View File

@ -940,6 +940,8 @@ fn test_spawn_sched_childs_on_default_sched() {
#[cfg(test)]
pub mod testrt {
use libc;
#[nolink]
pub extern {
unsafe fn rust_dbg_lock_create() -> *libc::c_void;

View File

@ -3409,7 +3409,8 @@ mod tests {
fail_unless!(rsplit(~[], f) == ~[]);
fail_unless!(rsplit(~[1, 2], f) == ~[~[1, 2]]);
fail_unless!(rsplit(~[1, 2, 3], f) == ~[~[1, 2], ~[]]);
fail_unless!(rsplit(~[1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]);
fail_unless!(rsplit(~[1, 2, 3, 4, 3, 5], f) ==
~[~[1, 2], ~[4], ~[5]]);
}
#[test]
@ -3427,9 +3428,12 @@ mod tests {
fn test_partition() {
// FIXME (#4355 maybe): using v.partition here crashes
fail_unless!(partition(~[], |x: &int| *x < 3) == (~[], ~[]));
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 4) == (~[1, 2, 3], ~[]));
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 2) == (~[1], ~[2, 3]));
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 0) == (~[], ~[1, 2, 3]));
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 4) ==
(~[1, 2, 3], ~[]));
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 2) ==
(~[1], ~[2, 3]));
fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 0) ==
(~[], ~[1, 2, 3]));
}
#[test]

View File

@ -704,7 +704,8 @@ pub fn trans_arg_expr(bcx: block,
// FIXME(#3548) use the adjustments table
match autoref_arg {
DoAutorefArg => {
fail_unless!(!bcx.ccx().maps.moves_map.contains_key(&arg_expr.id));
fail_unless!(!
bcx.ccx().maps.moves_map.contains_key(&arg_expr.id));
val = arg_datum.to_ref_llval(bcx);
}
DontAutorefArg => {

View File

@ -90,7 +90,8 @@ fn should_promote_desc() {
#[test]
fn should_promote_trait_method_desc() {
let doc = test::mk_doc(~"trait i { #[doc = \"desc\"] fn a(); }");
fail_unless!(doc.cratemod().traits()[0].methods[0].brief == Some(~"desc"));
fail_unless!(doc.cratemod().traits()[0].methods[0].brief ==
Some(~"desc"));
}
#[test]

View File

@ -380,7 +380,8 @@ mod test {
#[test]
pub fn extract_mods_deep() {
let doc = mk_doc(~"mod a { mod b { mod c { } } }");
fail_unless!(doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c");
fail_unless!(doc.cratemod().mods()[0].mods()[0].mods()[0].name() ==
~"c");
}
#[test]

View File

@ -160,7 +160,8 @@ fn pandoc_header_id(header: &str) -> ~str {
#[test]
fn should_remove_punctuation_from_headers() {
fail_unless!(pandoc_header_id(~"impl foo of bar<A>") == ~"impl-foo-of-bara");
fail_unless!(pandoc_header_id(~"impl foo of bar<A>") ==
~"impl-foo-of-bara");
fail_unless!(pandoc_header_id(~"impl of num::num for int")
== ~"impl-of-numnum-for-int");
fail_unless!(pandoc_header_id(~"impl of num::num for int/&")

View File

@ -752,7 +752,8 @@ fn should_write_impl_header() {
#[test]
fn should_write_impl_header_with_trait() {
let markdown = test::render(~"impl j for int { fn a() { } }");
fail_unless!(str::contains(markdown, ~"## Implementation of `j` for `int`"));
fail_unless!(str::contains(markdown,
~"## Implementation of `j` for `int`"));
}
#[test]

View File

@ -265,7 +265,8 @@ fn should_execute_on_trait_method_section_bodies() {
# Header\n\
Body \"]\
fn a(); }");
fail_unless!(doc.cratemod().traits()[0].methods[0].sections[0].body == ~"Body");
fail_unless!(doc.cratemod().traits()[0].methods[0].sections[0].body ==
~"Body");
}
#[test]
@ -288,7 +289,8 @@ fn should_execute_on_impl_method_section_bodies() {
# Header\n\
Body \"]\
fn a() { } }");
fail_unless!(doc.cratemod().impls()[0].methods[0].sections[0].body == ~"Body");
fail_unless!(doc.cratemod().impls()[0].methods[0].sections[0].body ==
~"Body");
}
#[cfg(test)]

View File

@ -92,7 +92,8 @@ fn should_add_fn_sig() {
#[test]
fn should_add_foreign_fn_sig() {
let doc = test::mk_doc(~"extern mod a { fn a<T>() -> int; }");
fail_unless!(doc.cratemod().nmods()[0].fns[0].sig == Some(~"fn a<T>() -> int"));
fail_unless!(doc.cratemod().nmods()[0].fns[0].sig ==
Some(~"fn a<T>() -> int"));
}
fn fold_const(
@ -165,7 +166,8 @@ fn fold_enum(
#[test]
fn should_add_variant_sigs() {
let doc = test::mk_doc(~"enum a { b(int) }");
fail_unless!(doc.cratemod().enums()[0].variants[0].sig == Some(~"b(int)"));
fail_unless!(doc.cratemod().enums()[0].variants[0].sig ==
Some(~"b(int)"));
}
fn fold_trait(
@ -407,7 +409,8 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
#[test]
fn should_add_struct_defs() {
let doc = test::mk_doc(~"struct S { field: () }");
fail_unless!((&doc.cratemod().structs()[0].sig).get().contains("struct S {"));
fail_unless!((&doc.cratemod().structs()[0].sig).get().contains(
"struct S {"));
}
#[test]

View File

@ -519,7 +519,8 @@ mod tests {
let _ = p.recv();
do arc2.access_cond |one, cond| {
cond.signal();
fail_unless!(*one == 0); // Parent should fail when it wakes up.
// Parent should fail when it wakes up.
fail_unless!(*one == 0);
}
}

View File

@ -1238,7 +1238,8 @@ mod tests {
#[test]
pub fn test_from_bools() {
fail_unless!(from_bools([true, false, true, true]).to_str() == ~"1011");
fail_unless!(from_bools([true, false, true, true]).to_str() ==
~"1011");
}
#[test]

View File

@ -128,7 +128,8 @@ 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") == ~"d9130a8164549fe818874806e1c7014b");
fail_unless!(md4_text(~"message digest") ==
~"d9130a8164549fe818874806e1c7014b");
fail_unless!(md4_text(~"abcdefghijklmnopqrstuvwxyz") ==
~"d79e1c308aa5bbcdeea8ed63df412da9");
fail_unless!(md4_text(

View File

@ -971,7 +971,8 @@ mod tests {
fail_unless!(encode_component("") == ~"");
fail_unless!(encode_component("http://example.com") ==
~"http%3A%2F%2Fexample.com");
fail_unless!(encode_component("foo bar% baz") == ~"foo%20bar%25%20baz");
fail_unless!(encode_component("foo bar% baz") ==
~"foo%20bar%25%20baz");
fail_unless!(encode_component(" ") == ~"%20");
fail_unless!(encode_component("!") == ~"%21");
fail_unless!(encode_component("#") == ~"%23");
@ -1065,7 +1066,8 @@ mod tests {
let mut m = LinearMap::new();
m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]);
fail_unless!(encode_form_urlencoded(&m) == ~"foo+bar=abc&foo+bar=12+%3D+34");
fail_unless!(encode_form_urlencoded(&m) ==
~"foo+bar=abc&foo+bar=12+%3D+34");
}
#[test]

View File

@ -962,7 +962,9 @@ mod tests {
for vec::each(pairs) |p| {
match *p {
(ref a, ref b) => { fail_unless!((*a == b.desc.name.to_str())); }
(ref a, ref b) => {
fail_unless!((*a == b.desc.name.to_str()));
}
}
}
}

View File

@ -22,10 +22,6 @@ const NSEC_PER_SEC: i32 = 1_000_000_000_i32;
pub mod rustrt {
use super::Tm;
#[cfg(target_os = "linux")]
#[link_args = "-lrt"]
pub extern {}
#[abi = "cdecl"]
pub extern {
pub unsafe fn get_time(sec: &mut i64, nsec: &mut i32);
@ -1164,10 +1160,14 @@ mod tests {
fail_unless!(test(~"6", ~"%w"));
fail_unless!(test(~"2009", ~"%Y"));
fail_unless!(test(~"09", ~"%y"));
fail_unless!(result::unwrap(strptime(~"UTC", ~"%Z")).tm_zone == ~"UTC");
fail_unless!(result::unwrap(strptime(~"PST", ~"%Z")).tm_zone == ~"");
fail_unless!(result::unwrap(strptime(~"-0000", ~"%z")).tm_gmtoff == 0);
fail_unless!(result::unwrap(strptime(~"-0800", ~"%z")).tm_gmtoff == 0);
fail_unless!(result::unwrap(strptime(~"UTC", ~"%Z")).tm_zone ==
~"UTC");
fail_unless!(result::unwrap(strptime(~"PST", ~"%Z")).tm_zone ==
~"");
fail_unless!(result::unwrap(strptime(~"-0000", ~"%z")).tm_gmtoff ==
0);
fail_unless!(result::unwrap(strptime(~"-0800", ~"%z")).tm_gmtoff ==
0);
fail_unless!(test(~"%", ~"%%"));
}

View File

@ -790,7 +790,8 @@ mod test_treemap {
fail_unless!(r.key.cmp(&parent.key) == Greater);
let red = r.level == parent.level;
if parent_red { fail_unless!(!red) } // no dual horizontal links
fail_unless!(red || r.level == parent.level - 1); // right red or black
// Right red or black
fail_unless!(red || r.level == parent.level - 1);
check_left(&r.left, r);
check_right(&r.right, r, red);
}

View File

@ -1859,7 +1859,8 @@ 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) == rust_handle_size);
fail_unless!((4u+foreign_handle_size as uint) ==
rust_handle_size);
}
}
#[test]
@ -1873,7 +1874,8 @@ pub mod test {
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
// FIXME #1645 .. see note above about struct padding
fail_unless!((4u+foreign_handle_size as uint) == rust_handle_size);
fail_unless!((4u+foreign_handle_size as uint) ==
rust_handle_size);
}
}

View File

@ -54,7 +54,8 @@ impl gen_send for message {
message(ref _id, span, ref tys, this, Some(ref next_state)) => {
debug!("pipec: next state exists");
let next = this.proto.get_state(next_state.state);
fail_unless!(next_state.tys.len() == next.generics.ty_params.len());
fail_unless!(next_state.tys.len() ==
next.generics.ty_params.len());
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
let args_ast = vec::map2(arg_names, *tys, |n, t| cx.arg(*n, *t));

View File

@ -405,7 +405,9 @@ pub impl Printer {
self.print(x, L);
match x {
BREAK(b) => self.left_total += b.blank_space,
STRING(_, len) => { fail_unless!((len == L)); self.left_total += len; }
STRING(_, len) => {
fail_unless!((len == L)); self.left_total += len;
}
_ => ()
}
if self.left != self.right {

View File

@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type point = { x: int, y: int };
struct Point {
x: int,
y: int,
}
fn a() {
let mut p = ~[1];

View File

@ -8,17 +8,33 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct Rec {
f: ~int,
}
struct Outer {
f: Inner
}
struct Inner {
g: Innermost
}
struct Innermost {
h: ~int,
}
fn borrow(_v: &int) {}
fn box_mut(v: @mut ~int) {
borrow(*v); //~ ERROR illegal borrow unless pure
}
fn box_mut_rec(v: @mut {f: ~int}) {
fn box_mut_rec(v: @mut Rec) {
borrow(v.f); //~ ERROR illegal borrow unless pure
}
fn box_mut_recs(v: @mut {f: {g: {h: ~int}}}) {
fn box_mut_recs(v: @mut Outer) {
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
}
@ -26,11 +42,11 @@ fn box_imm(v: @~int) {
borrow(*v); // OK
}
fn box_imm_rec(v: @{f: ~int}) {
fn box_imm_rec(v: @Rec) {
borrow(v.f); // OK
}
fn box_imm_recs(v: @{f: {g: {h: ~int}}}) {
fn box_imm_recs(v: @Outer) {
borrow(v.f.g.h); // OK
}
@ -38,13 +54,14 @@ fn box_const(v: @const ~int) {
borrow(*v); //~ ERROR illegal borrow unless pure
}
fn box_const_rec(v: @const {f: ~int}) {
fn box_const_rec(v: @const Rec) {
borrow(v.f); //~ ERROR illegal borrow unless pure
}
fn box_const_recs(v: @const {f: {g: {h: ~int}}}) {
fn box_const_recs(v: @const Outer) {
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
}
fn main() {
}

View File

@ -8,17 +8,33 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct Rec {
f: ~int,
}
struct Outer {
f: Inner
}
struct Inner {
g: Innermost
}
struct Innermost {
h: ~int,
}
fn borrow(_v: &int) {}
fn box_mut(v: &mut ~int) {
borrow(*v); // OK: &mut -> &imm
}
fn box_mut_rec(v: &mut {f: ~int}) {
fn box_mut_rec(v: &mut Rec) {
borrow(v.f); // OK: &mut -> &imm
}
fn box_mut_recs(v: &mut {f: {g: {h: ~int}}}) {
fn box_mut_recs(v: &mut Outer) {
borrow(v.f.g.h); // OK: &mut -> &imm
}
@ -26,11 +42,11 @@ fn box_imm(v: &~int) {
borrow(*v); // OK
}
fn box_imm_rec(v: &{f: ~int}) {
fn box_imm_rec(v: &Rec) {
borrow(v.f); // OK
}
fn box_imm_recs(v: &{f: {g: {h: ~int}}}) {
fn box_imm_recs(v: &Outer) {
borrow(v.f.g.h); // OK
}
@ -38,11 +54,11 @@ fn box_const(v: &const ~int) {
borrow(*v); //~ ERROR illegal borrow unless pure
}
fn box_const_rec(v: &const {f: ~int}) {
fn box_const_rec(v: &const Rec) {
borrow(v.f); //~ ERROR illegal borrow unless pure
}
fn box_const_recs(v: &const {f: {g: {h: ~int}}}) {
fn box_const_recs(v: &const Outer) {
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
}

View File

@ -1,3 +1,5 @@
// xfail-test
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -1,3 +1,5 @@
// xfail-test
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -13,10 +13,16 @@ extern mod std;
use std::oldmap::HashMap;
use std::bitv;
type fn_info = {vars: HashMap<uint, var_info>};
type var_info = {a: uint, b: uint};
struct FnInfo {
vars: HashMap<uint, VarInfo>
}
fn bitv_to_str(enclosing: fn_info, v: ~bitv::Bitv) -> str {
struct VarInfo {
a: uint,
b: uint,
}
fn bitv_to_str(enclosing: FnInfo, v: ~bitv::Bitv) -> str {
let s = "";
// error is that the value type in the hash map is var_info, not a box

View File

@ -1,17 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Issue #1763 - infer types correctly
type actor<T> = { //~ ERROR type parameter `T` is unused
unused: bool
};
fn main() {}

View File

@ -16,19 +16,19 @@ trait siphash {
}
fn siphash(k0 : u64, k1 : u64) -> siphash {
type sipstate = {
mut v0 : u64,
mut v1 : u64,
};
struct SipState {
v0: u64,
v1: u64,
}
fn mk_result(st : sipstate) -> u64 {
fn mk_result(st : SipState) -> u64 {
let v0 = st.v0,
v1 = st.v1;
return v0 ^ v1;
}
impl siphash for sipstate {
impl siphash for SipState {
fn reset() {
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
//~^ ERROR unresolved name: `k0`.

View File

@ -10,17 +10,16 @@
extern mod std;
trait siphash {
trait SipHash {
fn reset();
}
fn siphash(k0 : u64) -> siphash {
type sipstate = {
mut v0 : u64,
};
fn siphash(k0 : u64) -> SipHash {
struct SipState {
v0: u64,
}
impl siphash for sipstate {
impl SipHash for SipState {
fn reset() {
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
//~^ ERROR unresolved name: `k0`.

View File

@ -14,7 +14,9 @@ struct Deserializer : std::serialization::deserializer{ //~ ERROR obsolete synta
x: ()
}
type foo = {a: (),};
struct Foo {
a: ()
}
fn deserialize_foo<__D: std::serialization::deserializer>(&&__d: __D) {
}

View File

@ -8,6 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main(foo: {x: int, y: int}) {
//~^ ERROR Wrong type in main function: found `extern fn({x: int,y: int})`
struct S {
x: int,
y: int,
}
fn main(foo: S) {
//~^ ERROR Wrong type in main function: found `extern fn(S)`
}

View File

@ -1,25 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: mismatched types
struct S {
g: ~[int]
}
fn main() {
let v = S {g: ~[0]};
fn f(&&v: {g: ~[const int]}) {
v.g = ~[3]
}
f(v);
}

View File

@ -12,6 +12,10 @@
// Test rules governing higher-order pure fns.
struct S<'self> {
f: &'self fn(uint)
}
pure fn range(from: uint, to: uint, f: fn(uint)) {
let mut i = from;
while i < to {
@ -34,11 +38,11 @@ pure fn range4(from: uint, to: uint) {
range(from, to, print) //~ ERROR access to impure function prohibited in pure context
}
pure fn range5(from: uint, to: uint, x: {f: fn(uint)}) {
pure fn range5<'a>(from: uint, to: uint, x: S<'a>) {
range(from, to, x.f) //~ ERROR access to impure function prohibited in pure context
}
pure fn range6(from: uint, to: uint, x: @{f: fn(uint)}) {
pure fn range6<'a>(from: uint, to: uint, x: @S<'a>) {
range(from, to, x.f) //~ ERROR access to impure function prohibited in pure context
}

View File

@ -8,7 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pure fn range(from: uint, to: uint, f: fn(uint) -> bool) {
struct S<'self> {
x: &'self fn(uint)
}
pure fn range<'a>(from: uint, to: uint, f: &'a fn(uint) -> bool) {
let mut i = from;
while i < to {
if !f(i) {return;} // Note: legal to call argument, even if it is not pure.
@ -16,13 +20,13 @@ pure fn range(from: uint, to: uint, f: fn(uint) -> bool) {
}
}
pure fn range2(from: uint, to: uint, f: fn(uint)) {
pure fn range2<'a>(from: uint, to: uint, f: &'a fn(uint)) {
for range(from, to) |i| {
f(i*2u);
}
}
pure fn range3(from: uint, to: uint, f: {x: fn(uint)}) {
pure fn range3<'a>(from: uint, to: uint, f: S<'a>) {
for range(from, to) |i| {
(f.x)(i*2u); //~ ERROR access to impure function prohibited
}

View File

@ -1,3 +1,6 @@
// xfail-fast
// xfail-test
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type item_ty_yes0 = {
x: &uint //~ ERROR Illegal anonymous lifetime: anonymous lifetimes are not permitted here
};
type item_ty_yes1 = {
struct item_ty_yes0 {
x: &'self uint
};
}
type item_ty_yes2 = {
x: &'foo uint //~ ERROR Illegal lifetime &foo: only 'self is allowed allowed as part of a type declaration
};
struct item_ty_yes1 {
x: &'self uint
}
struct item_ty_yes2 {
x: &'a uint //~ ERROR only 'self is allowed
}
fn main() {}

View File

@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type point = {x: int, y: int};
struct point {
x: int,
y: int,
}
fn x_coord(p: &r/point) -> &r/int {
return &p.x;

View File

@ -13,7 +13,10 @@
type a<'self> = &'self int;
type b<'self> = @a<'self>;
type c<'self> = {f: @b<'self>};
struct c<'self> {
f: @b<'self>
}
trait set_f<'self> {
fn set_f_ok(b: @b<'self>);

View File

@ -8,12 +8,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type foo = {a: int, b: int};
type bar = {a: int, b: uint};
struct foo {
a: int,
b: int,
}
struct bar {
a: int,
b: uint,
}
fn want_foo(f: foo) {}
fn have_bar(b: bar) {
want_foo(b); //~ ERROR (in field `b`, expected int but found uint)
want_foo(b); //~ ERROR (expected struct foo but found struct bar)
}
fn main() {}

View File

@ -8,12 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type foo = {a: int, b: int};
struct foo {
a: int,
b: int,
}
type bar = @foo;
fn want_foo(f: foo) {}
fn have_bar(b: bar) {
want_foo(b); //~ ERROR (expected record but found @-ptr)
want_foo(b); //~ ERROR (expected struct foo but found @-ptr)
}
fn main() {}

View File

@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:illegal recursive type
type t1 = {foo: int, foolish: t1};
// error-pattern:this type cannot be instantiated
struct t1 {
foo: int,
foolish: t1
}
fn main() { }

View File

@ -22,5 +22,4 @@ fn main() {
+ ~"very" + ~"very" + ~"long" + ~"string",
None => ~"none"
};
fail_unless!(y == ~"some(_)");
}

View File

@ -13,5 +13,4 @@
fn main() {
let x = Some(3);
let y = match x { Some(_) => ~"some(_)", None => ~"none" };
fail_unless!(y == ~"some(_)");
}

View File

@ -12,4 +12,4 @@
fn f(f: @fn(int)) { f(10) }
fn main() { do f |i| { assert i == 10 } }
fn main() { do f |i| { fail_unless!(i == 10) } }

View File

@ -14,7 +14,10 @@ fn test00_start(ch: chan_t<int>, message: int) { send(ch, message); }
type task_id = int;
type port_id = int;
enum chan_t<T> = {task: task_id, port: port_id};
struct chan_t<T> {
task: task_id,
port: port_id,
}
fn send<T:Owned>(ch: chan_t<T>, data: T) { fail!(); }

View File

@ -10,7 +10,7 @@
// In this case, the code should compile but
// the assert should fail at runtime
// error-pattern:Assertion same_length(chars, ints) failed
// error-pattern:assertion failed
extern mod std;
use core::vec::{same_length, zip};

View File

@ -12,6 +12,6 @@
pub fn main() {
let i32_c: int = 0x10101010;
assert (i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3));
fail_unless!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3));
}

View File

@ -17,13 +17,13 @@ trait MyIter {
}
impl MyIter for &'self [int] {
pure fn test_imm(&self) { assert self[0] == 1 }
pure fn test_const(&const self) { assert self[0] == 1 }
pure fn test_imm(&self) { fail_unless!(self[0] == 1) }
pure fn test_const(&const self) { fail_unless!(self[0] == 1) }
}
impl MyIter for &'self str {
pure fn test_imm(&self) { assert *self == "test" }
pure fn test_const(&const self) { assert *self == "test" }
pure fn test_imm(&self) { fail_unless!(*self == "test") }
pure fn test_const(&const self) { fail_unless!(*self == "test") }
}
pub fn main() {

View File

@ -1,3 +1,5 @@
// xfail-pretty
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -12,7 +12,7 @@ struct Foo {a: int, b: uint}
enum bar { u(@Foo), w(int), }
pub fn main() {
assert (match u(@Foo{a: 10, b: 40u}) {
fail_unless!(match u(@Foo{a: 10, b: 40u}) {
u(@Foo{a: a, b: b}) => { a + (b as int) }
_ => { 66 }
} == 50);

View File

@ -11,9 +11,9 @@
// Regression test that rustc doesn't recurse infinitely substituting
// the boxed type parameter
type Tree<T> = {
parent: Option<T>,
};
struct Tree<T> {
parent: Option<T>
}
fn empty<T>() -> Tree<T> { fail!() }
@ -27,8 +27,8 @@ fn Box() -> Box {
}
}
enum layout_data = {
struct LayoutData {
box: Option<@Box>
};
}
pub fn main() { }

View File

@ -30,7 +30,7 @@ fn atoll(s: ~str) -> i64 {
pub fn main() {
unsafe {
fail_unless!(atol(~"1024") * 10 == atol(~"10240"));
assert (atoll(~"11111111111111111") * 10i64)
== atoll(~"111111111111111110");
fail_unless!((atoll(~"11111111111111111") * 10i64)
== atoll(~"111111111111111110"));
}
}

View File

@ -12,7 +12,7 @@
fn adder(+x: @int, +y: @int) -> int { return *x + *y; }
fn failer() -> @int { fail!(); }
pub fn main() {
assert(result::is_err(&task::try(|| {
fail_unless!(result::is_err(&task::try(|| {
adder(@2, failer()); ()
})));
}

View File

@ -12,9 +12,9 @@
// storing closure data (as we used to do), the u64 would
// overwrite the u16.
type pair<A,B> = {
struct Pair<A,B> {
a: A, b: B
};
}
fn f<A:Copy + &static>(a: A, b: u16) -> @fn() -> (A, u16) {
let result: @fn() -> (A, u16) = || (a, b);

View File

@ -22,7 +22,7 @@ pub fn main() {
_ => fail!()
}
match Y {
Bar(s) => assert(s == 2654435769),
Bar(s) => fail_unless!(s == 2654435769),
_ => fail!()
}
match Z {

View File

@ -11,5 +11,5 @@
const a: *u8 = 0 as *u8;
fn main() {
assert a == ptr::null();
}
fail_unless!(a == ptr::null());
}

View File

@ -16,6 +16,6 @@ const a: &static/int = &10;
const b: *int = a as *int;
fn main() {
assert x as *libc::c_void == y;
assert a as *int == b;
}
fail_unless!(x as *libc::c_void == y);
fail_unless!(a as *int == b);
}

View File

@ -17,9 +17,9 @@ const a: uint = cci_const::uint_val;
const b: uint = cci_const::uint_expr + 5;
fn main() {
assert a == 12;
fail_unless!(a == 12);
let foo2 = a;
assert foo2 == cci_const::uint_val;
assert b == cci_const::uint_expr + 5;
assert foo == cci_const::foopy;
fail_unless!(foo2 == cci_const::uint_val);
fail_unless!(b == cci_const::uint_expr + 5);
fail_unless!(foo == cci_const::foopy);
}

View File

@ -16,5 +16,5 @@ use cci_const::bar;
const foo: *u8 = bar;
fn main() {
assert foo == cci_const::bar;
fail_unless!(foo == cci_const::bar);
}

View File

@ -18,6 +18,6 @@ const C: E = S1 { u: 23 };
fn main() {
match C {
S0 { _ } => fail!(),
S1 { u } => assert u == 23
S1 { u } => fail_unless!(u == 23)
}
}

View File

@ -19,7 +19,7 @@ pub fn main() {
_ => fail!()
}
match C1 {
V1(n) => assert(n == 0xDEADBEE),
V1(n) => fail_unless!(n == 0xDEADBEE),
_ => fail!()
}
}

View File

@ -13,7 +13,7 @@ const C: &static/[E] = &[V0, V1(0xDEADBEE), V0];
pub fn main() {
match C[1] {
V1(n) => assert(n == 0xDEADBEE),
V1(n) => fail_unless!(n == 0xDEADBEE),
_ => fail!()
}
match C[2] {

View File

@ -13,7 +13,7 @@ const C: [E * 3] = [V0, V1(0xDEADBEE), V0];
pub fn main() {
match C[1] {
V1(n) => assert(n == 0xDEADBEE),
V1(n) => fail_unless!(n == 0xDEADBEE),
_ => fail!()
}
match C[2] {

View File

@ -20,6 +20,6 @@ const y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0,
pub fn main() {
let (p, _) = y.x;
fail_unless!(p == 0xf0f0f0f0_f0f0f0f0);
fail_unless!(p == - 1085102592571150096);
io::println(fmt!("0x%x", p as uint));
}

View File

@ -14,9 +14,9 @@ const b: *u8 = c as *u8;
fn main() {
let foo = &a as *u8;
assert unsafe { str::raw::from_bytes(a) } == ~"hi\x00";
assert unsafe { str::raw::from_buf(foo) } == ~"hi";
assert unsafe { str::raw::from_buf(b) } == ~"hi";
assert unsafe { *b == a[0] };
assert unsafe { *(&c[0] as *u8) == a[0] };
}
fail_unless!(unsafe { str::raw::from_bytes(a) } == ~"hi\x00");
fail_unless!(unsafe { str::raw::from_buf(foo) } == ~"hi");
fail_unless!(unsafe { str::raw::from_buf(b) } == ~"hi");
fail_unless!(unsafe { *b == a[0] });
fail_unless!(unsafe { *(&c[0] as *u8) == a[0] });
}

View File

@ -11,5 +11,5 @@
fn f(f: &fn(int)) { f(10) }
pub fn main() {
do f() |i| { assert i == 10 }
do f() |i| { fail_unless!(i == 10) }
}

View File

@ -11,5 +11,5 @@
fn f(f: @fn(int)) { f(10) }
pub fn main() {
do f() |i| { assert i == 10 }
do f() |i| { fail_unless!(i == 10) }
}

View File

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type quux = {bar: int};
struct Quux {
bar: int
}
fn g(i: int) { }
fn f(foo: @@quux) { g(foo.bar); }
fn f(foo: @@Quux) { g(foo.bar); }
pub fn main() { }

View File

@ -20,12 +20,12 @@ fn main () {
let a2 = B2 as int;
let a3 = A2 as float;
let a4 = B2 as float;
assert(c1 == 1);
assert(c2 == 2);
assert(c3 == 1.0);
assert(c4 == 2.0);
assert(a1 == 1);
assert(a2 == 2);
assert(a3 == 1.0);
assert(a4 == 2.0);
fail_unless!(c1 == 1);
fail_unless!(c2 == 2);
fail_unless!(c3 == 1.0);
fail_unless!(c4 == 2.0);
fail_unless!(a1 == 1);
fail_unless!(a2 == 2);
fail_unless!(a3 == 1.0);
fail_unless!(a4 == 2.0);
}

View File

@ -14,6 +14,6 @@ extern mod std;
pub fn main() {
// Bare functions should just be a pointer
assert sys::rustrt::size_of::<fn()>() ==
sys::rustrt::size_of::<int>();
fail_unless!(sys::rustrt::size_of::<fn()>() ==
sys::rustrt::size_of::<int>());
}

View File

@ -10,10 +10,12 @@
type foo<T> = {a: T};
struct Foo<T> {
a: T
}
type bar<T> = foo<T>;
type Bar<T> = Foo<T>;
fn takebar<T>(b: bar<T>) { }
fn takebar<T>(b: Bar<T>) { }
pub fn main() { }

View File

@ -20,7 +20,7 @@ pub fn main() {
match getopts(args, opts) {
result::Ok(ref m) =>
assert !opt_present(m, "b"),
fail_unless!(!opt_present(m, "b")),
result::Err(ref f) => fail!(fail_str(copy *f))
};

View File

@ -28,11 +28,11 @@ pub mod pipes {
terminated
}
pub type packet<T> = {
pub struct packet<T> {
state: state,
blocked_task: Option<task::Task>,
payload: Option<T>
};
}
pub fn packet<T:Owned>() -> *packet<T> {
unsafe {

View File

@ -70,14 +70,14 @@ fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] {
grid.push(row)
}
let width = grid[0].len();
for grid.each |row| { assert row.len() == width }
for grid.each |row| { fail_unless!(row.len() == width) }
grid
}
mod test {
#[test]
pub fn trivial_to_str() {
assert lambda.to_str() == "\\"
fail_unless!(lambda.to_str() == "\\")
}
#[test]

View File

@ -66,7 +66,7 @@ mod test_multi_attr_outer {
#[attr1 = "val"]
#[attr2 = "val"]
type t = {x: int};
struct t {x: int}
}
mod test_stmt_single_attr_outer {

View File

@ -19,5 +19,5 @@ pub fn main() {
})
)
assert(mylambda_tt!(y, y * 2)(8) == 16)
fail_unless!(mylambda_tt!(y, y * 2)(8) == 16)
}

View File

@ -23,7 +23,7 @@ macro_rules! overly_complicated (
)
pub fn main() {
fail_unless!(overly_complicated!(f, x, Option<uint>, { return Some(x)); },
Some(8u), Some(y), y) == 8u
fail_unless!(overly_complicated!(f, x, Option<uint>, { return Some(x); },
Some(8u), Some(y), y) == 8u)
}

View File

@ -42,8 +42,8 @@ fn transform(x: Option<int>) -> Option<~str> {
pub fn main() {
fail_unless!(transform(Some(10)) == Some(~"11"));
fail_unless!(transform(None) == None);
assert (~[~"hi"])
fail_unless!((~[~"hi"])
.bind(|x| ~[copy *x, *x + ~"!"] )
.bind(|x| ~[copy *x, *x + ~"?"] ) ==
~[~"hi", ~"hi?", ~"hi!", ~"hi!?"];
~[~"hi", ~"hi?", ~"hi!", ~"hi!?"]);
}

View File

@ -47,6 +47,6 @@ fn getbig(a0: int,
}
pub fn main() {
let a = 10000;
let a = 1000;
getbig(a, a+1, a+2, a+3, a+4, a+5, a+6, a+7, a+8, a+9);
}

View File

@ -1,3 +1,5 @@
// xfail-pretty
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -651,8 +651,8 @@ pub fn main() {
io::println(fmt!("val: %s", *s));
}
error!("%?", copy u.vals);
assert u.vals == ~[
fail_unless!(u.vals == ~[
~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3", ~"12"
];
]);
}
}

View File

@ -153,6 +153,6 @@ pub fn main() {
for (copy v.types).each {|s|
io::println(fmt!("type: %s", s));
}
assert v.types == ["bool", "int", "i8", "i16",
"[", "int", "]"];
fail_unless!(v.types == ["bool", "int", "i8", "i16",
"[", "int", "]"]);
}

View File

@ -8,10 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type point = { x: int, y: int };
type character = { pos: ~point };
struct Point {
x: int,
y: int
}
fn get_x(x: &r/character) -> &r/int {
struct Character {
pos: ~Point
}
fn get_x(x: &'r Character) -> &'r int {
// interesting case because the scope of this
// borrow of the unique pointer is in fact
// larger than the fn itself

View File

@ -11,9 +11,12 @@
use core::comm::*;
// tests that ctrl's type gets inferred properly
type command<K, V> = {key: K, val: V};
struct Command<K, V> {
key: K,
val: V
}
fn cache_server<K:Owned,V:Owned>(c: Chan<Chan<command<K, V>>>) {
fn cache_server<K:Owned,V:Owned>(c: Chan<Chan<Command<K, V>>>) {
let (ctrl_port, ctrl_chan) = stream();
c.send(ctrl_chan);
}

View File

@ -13,6 +13,6 @@ pub fn main() {
let asdf_fdsa = ~"<.<";
fail_unless!((concat_idents!(asd, f_f, dsa) == ~"<.<"));
assert (stringify!(use_mention_distinction) ==
fail_unless!(stringify!(use_mention_distinction) ==
~"use_mention_distinction");
}

View File

@ -1,7 +1,7 @@
/* this is for run-pass/syntax-extension-source-utils.rs */
{
assert(file!().ends_with("includeme.fragment"));
assert(line!() == 5u);
fail_unless!(file!().ends_with("includeme.fragment"));
fail_unless!(line!() == 5u);
fmt!("victory robot %u", line!())
}

View File

@ -21,17 +21,17 @@ macro_rules! indirect_line( () => ( line!() ) )
pub fn main() {
fail_unless!((line!() == 23));
fail_unless!((col!() == 11));
//fail_unless!((col!() == 11));
fail_unless!((indirect_line!() == 25));
fail_unless!((file!().to_owned().ends_with(~"syntax-extension-source-utils.rs")));
fail_unless!((stringify!((2*3) + 5).to_owned() == ~"( 2 * 3 ) + 5"));
assert(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned()
fail_unless!(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned()
== ~"victory robot 6");
assert(
fail_unless!(
include_str!("syntax-extension-source-utils-files/includeme.fragment").to_owned()
.starts_with(~"/* this is for "));
assert(
fail_unless!(
include_bin!("syntax-extension-source-utils-files/includeme.fragment")
[1] == (42 as u8)); // '*'
// The Windows tests are wrapped in an extra module for some reason

View File

@ -28,11 +28,11 @@ fn checktests() {
// Pull the tests out of the secreturn test module
let tests = __test::tests;
assert vec::any(
fail_unless!(vec::any(
tests,
|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore);
|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
assert vec::any(
fail_unless!(vec::any(
tests,
|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore);
|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore));
}

View File

@ -31,6 +31,6 @@ pure fn mi(v: int) -> MyInt { MyInt { val: v } }
pub fn main() {
let (x, y) = (mi(3), mi(5));
let z = f(x, y);
assert z.val == 8
fail_unless!(z.val == 8)
}

View File

@ -8,14 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct S<T> {
a: T,
b: uint,
}
fn range(lo: uint, hi: uint, it: fn(uint)) {
let mut lo_ = lo;
while lo_ < hi { it(lo_); lo_ += 1u; }
}
fn create_index<T>(index: ~[{a: T, b: uint}], hash_fn: extern fn(T) -> uint) {
fn create_index<T>(index: ~[S<T>], hash_fn: extern fn(T) -> uint) {
range(0u, 256u, |_i| { let bucket: ~[T] = ~[]; } )
}

View File

@ -22,7 +22,7 @@ pub fn main() {
fail_unless!((size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint));
// Alignment causes padding before the char and the u32.
assert (size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() ==
fail_unless!(size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() ==
16 as uint);
fail_unless!((size_of::<int>() == size_of::<uint>()));
fail_unless!((size_of::<{a: int, b: ()}>() == size_of::<int>()));

View File

@ -55,11 +55,11 @@ pub fn main() {
fail_unless!(Equal::isEq(leaf(cyan), leaf(cyan)));
fail_unless!(!Equal::isEq(leaf(cyan), leaf(yellow)));
assert Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(cyan)));
fail_unless!(Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(cyan))));
assert !Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(magenta)));
fail_unless!(!Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(magenta))));
log(error, "Assertions all succeeded!");
}

View File

@ -54,11 +54,11 @@ pub fn main() {
fail_unless!(leaf(cyan).isEq(leaf(cyan)));
fail_unless!(!leaf(cyan).isEq(leaf(yellow)));
assert branch(@leaf(magenta), @leaf(cyan))
.isEq(branch(@leaf(magenta), @leaf(cyan)));
fail_unless!(branch(@leaf(magenta), @leaf(cyan))
.isEq(branch(@leaf(magenta), @leaf(cyan))));
assert !branch(@leaf(magenta), @leaf(cyan))
.isEq(branch(@leaf(magenta), @leaf(magenta)));
fail_unless!(!branch(@leaf(magenta), @leaf(cyan))
.isEq(branch(@leaf(magenta), @leaf(magenta))));
log(error, "Assertions all succeeded!");
error!("Assertions all succeeded!");
}

View File

@ -12,13 +12,13 @@ fn test1() {
enum bar { u(~int), w(int), }
let x = u(~10);
assert match x {
fail_unless!(match x {
u(a) => {
log(error, a);
*a
}
_ => { 66 }
} == 10;
} == 10);
}
pub fn main() {

Some files were not shown because too many files have changed in this diff Show More