diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index e3336e24a6e..cde22afd34a 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -11,7 +11,6 @@ //! Unsafe casting functions use sys; -use unstable; use unstable::intrinsics; /// Casts the value at `src` to U. The two types must have the same length. diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs index 69312f3a97b..f46c8ab7ecc 100644 --- a/src/libstd/hash.rs +++ b/src/libstd/hash.rs @@ -488,7 +488,7 @@ mod tests { assert!(f == i && f == v); buf += ~[t as u8]; - stream_inc.input(~[t as u8]); + stream_inc.input([t as u8]); t += 1; } diff --git a/src/libstd/io.rs b/src/libstd/io.rs index aa312742e3e..4ce4ea108e5 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -1839,7 +1839,7 @@ mod tests { { let out: @io::Writer = result::get( - &io::file_writer(tmpfile, ~[io::Create, io::Truncate])); + &io::file_writer(tmpfile, [io::Create, io::Truncate])); out.write_str(frood); } let inp: @io::Reader = result::get(&io::file_reader(tmpfile)); @@ -1850,7 +1850,7 @@ mod tests { #[test] fn test_readchars_empty() { - do io::with_str_reader(~"") |inp| { + do io::with_str_reader("") |inp| { let res : ~[char] = inp.read_chars(128); assert_eq!(res.len(), 0); } @@ -1858,7 +1858,7 @@ mod tests { #[test] fn test_read_line_utf8() { - do io::with_str_reader(~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤") |inp| { + do io::with_str_reader("生锈的汤匙切肉汤hello生锈的汤匙切肉汤") |inp| { let line = inp.read_line(); assert_eq!(line, ~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤"); } @@ -1866,15 +1866,15 @@ mod tests { #[test] fn test_read_lines() { - do io::with_str_reader(~"a\nb\nc\n") |inp| { + do io::with_str_reader("a\nb\nc\n") |inp| { assert_eq!(inp.read_lines(), ~[~"a", ~"b", ~"c"]); } - do io::with_str_reader(~"a\nb\nc") |inp| { + do io::with_str_reader("a\nb\nc") |inp| { assert_eq!(inp.read_lines(), ~[~"a", ~"b", ~"c"]); } - do io::with_str_reader(~"") |inp| { + do io::with_str_reader("") |inp| { assert!(inp.read_lines().is_empty()); } } @@ -1909,7 +1909,7 @@ mod tests { #[test] fn test_readchar() { - do io::with_str_reader(~"生") |inp| { + do io::with_str_reader("生") |inp| { let res : char = inp.read_char(); assert_eq!(res as int, 29983); } @@ -1917,7 +1917,7 @@ mod tests { #[test] fn test_readchar_empty() { - do io::with_str_reader(~"") |inp| { + do io::with_str_reader("") |inp| { let res : char = inp.read_char(); assert_eq!(res as int, -1); } @@ -1966,7 +1966,7 @@ mod tests { #[test] fn file_writer_bad_name() { - match io::file_writer(&Path("?/?"), ~[]) { + match io::file_writer(&Path("?/?"), []) { result::Err(copy e) => { assert!(str::starts_with(e, "error opening")); } @@ -1987,15 +1987,15 @@ mod tests { #[test] fn bytes_buffer_overwrite() { let wr = BytesWriter(); - wr.write(~[0u8, 1u8, 2u8, 3u8]); + wr.write([0u8, 1u8, 2u8, 3u8]); assert!(*wr.bytes == ~[0u8, 1u8, 2u8, 3u8]); wr.seek(-2, SeekCur); - wr.write(~[4u8, 5u8, 6u8, 7u8]); + wr.write([4u8, 5u8, 6u8, 7u8]); assert!(*wr.bytes == ~[0u8, 1u8, 4u8, 5u8, 6u8, 7u8]); wr.seek(-2, SeekEnd); - wr.write(~[8u8]); + wr.write([8u8]); wr.seek(1, SeekSet); - wr.write(~[9u8]); + wr.write([9u8]); assert!(*wr.bytes == ~[0u8, 9u8, 4u8, 5u8, 8u8, 7u8]); } @@ -2085,7 +2085,7 @@ mod tests { } } -#[test] + #[test] fn test_read_write_f32() { let path = Path("tmp/lib-io-test-read-write-f32.tmp"); let f:f32 = 8.1250; diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index d5dc0dd4730..c6d183c6fb8 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -951,7 +951,6 @@ impl num::FromStrRadix for f32 { mod tests { use f32::*; use num::*; - use super::*; use prelude::*; #[test] diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 6e2496e2e45..262e4176c91 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -993,7 +993,6 @@ impl num::FromStrRadix for f64 { mod tests { use f64::*; use num::*; - use super::*; use prelude::*; #[test] diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index 681aafaab88..d04f12f6bd3 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -1251,101 +1251,101 @@ mod tests { #[test] pub fn test_from_str() { - assert_eq!(from_str(~"3"), Some(3.)); - assert_eq!(from_str(~"3.14"), Some(3.14)); - assert_eq!(from_str(~"+3.14"), Some(3.14)); - assert_eq!(from_str(~"-3.14"), Some(-3.14)); - assert_eq!(from_str(~"2.5E10"), Some(25000000000.)); - assert_eq!(from_str(~"2.5e10"), Some(25000000000.)); - assert_eq!(from_str(~"25000000000.E-10"), Some(2.5)); - assert_eq!(from_str(~"."), Some(0.)); - assert_eq!(from_str(~".e1"), Some(0.)); - assert_eq!(from_str(~".e-1"), Some(0.)); - assert_eq!(from_str(~"5."), Some(5.)); - assert_eq!(from_str(~".5"), Some(0.5)); - assert_eq!(from_str(~"0.5"), Some(0.5)); - assert_eq!(from_str(~"-.5"), Some(-0.5)); - assert_eq!(from_str(~"-5"), Some(-5.)); - assert_eq!(from_str(~"inf"), Some(infinity)); - assert_eq!(from_str(~"+inf"), Some(infinity)); - assert_eq!(from_str(~"-inf"), Some(neg_infinity)); + assert_eq!(from_str("3"), Some(3.)); + assert_eq!(from_str("3.14"), Some(3.14)); + assert_eq!(from_str("+3.14"), Some(3.14)); + assert_eq!(from_str("-3.14"), Some(-3.14)); + assert_eq!(from_str("2.5E10"), Some(25000000000.)); + assert_eq!(from_str("2.5e10"), Some(25000000000.)); + assert_eq!(from_str("25000000000.E-10"), Some(2.5)); + assert_eq!(from_str("."), Some(0.)); + assert_eq!(from_str(".e1"), Some(0.)); + assert_eq!(from_str(".e-1"), Some(0.)); + assert_eq!(from_str("5."), Some(5.)); + assert_eq!(from_str(".5"), Some(0.5)); + assert_eq!(from_str("0.5"), Some(0.5)); + assert_eq!(from_str("-.5"), Some(-0.5)); + assert_eq!(from_str("-5"), Some(-5.)); + assert_eq!(from_str("inf"), Some(infinity)); + assert_eq!(from_str("+inf"), Some(infinity)); + assert_eq!(from_str("-inf"), Some(neg_infinity)); // note: NaN != NaN, hence this slightly complex test - match from_str(~"NaN") { + match from_str("NaN") { Some(f) => assert!(f.is_NaN()), None => fail!() } // note: -0 == 0, hence these slightly more complex tests - match from_str(~"-0") { + match from_str("-0") { Some(v) if v.is_zero() => assert!(v.is_negative()), _ => fail!() } - match from_str(~"0") { + match from_str("0") { Some(v) if v.is_zero() => assert!(v.is_positive()), _ => fail!() } - assert!(from_str(~"").is_none()); - assert!(from_str(~"x").is_none()); - assert!(from_str(~" ").is_none()); - assert!(from_str(~" ").is_none()); - assert!(from_str(~"e").is_none()); - assert!(from_str(~"E").is_none()); - assert!(from_str(~"E1").is_none()); - assert!(from_str(~"1e1e1").is_none()); - assert!(from_str(~"1e1.1").is_none()); - assert!(from_str(~"1e1-1").is_none()); + assert!(from_str("").is_none()); + assert!(from_str("x").is_none()); + assert!(from_str(" ").is_none()); + assert!(from_str(" ").is_none()); + assert!(from_str("e").is_none()); + assert!(from_str("E").is_none()); + assert!(from_str("E1").is_none()); + assert!(from_str("1e1e1").is_none()); + assert!(from_str("1e1.1").is_none()); + assert!(from_str("1e1-1").is_none()); } #[test] pub fn test_from_str_hex() { - assert_eq!(from_str_hex(~"a4"), Some(164.)); - assert_eq!(from_str_hex(~"a4.fe"), Some(164.9921875)); - assert_eq!(from_str_hex(~"-a4.fe"), Some(-164.9921875)); - assert_eq!(from_str_hex(~"+a4.fe"), Some(164.9921875)); - assert_eq!(from_str_hex(~"ff0P4"), Some(0xff00 as float)); - assert_eq!(from_str_hex(~"ff0p4"), Some(0xff00 as float)); - assert_eq!(from_str_hex(~"ff0p-4"), Some(0xff as float)); - assert_eq!(from_str_hex(~"."), Some(0.)); - assert_eq!(from_str_hex(~".p1"), Some(0.)); - assert_eq!(from_str_hex(~".p-1"), Some(0.)); - assert_eq!(from_str_hex(~"f."), Some(15.)); - assert_eq!(from_str_hex(~".f"), Some(0.9375)); - assert_eq!(from_str_hex(~"0.f"), Some(0.9375)); - assert_eq!(from_str_hex(~"-.f"), Some(-0.9375)); - assert_eq!(from_str_hex(~"-f"), Some(-15.)); - assert_eq!(from_str_hex(~"inf"), Some(infinity)); - assert_eq!(from_str_hex(~"+inf"), Some(infinity)); - assert_eq!(from_str_hex(~"-inf"), Some(neg_infinity)); + assert_eq!(from_str_hex("a4"), Some(164.)); + assert_eq!(from_str_hex("a4.fe"), Some(164.9921875)); + assert_eq!(from_str_hex("-a4.fe"), Some(-164.9921875)); + assert_eq!(from_str_hex("+a4.fe"), Some(164.9921875)); + assert_eq!(from_str_hex("ff0P4"), Some(0xff00 as float)); + assert_eq!(from_str_hex("ff0p4"), Some(0xff00 as float)); + assert_eq!(from_str_hex("ff0p-4"), Some(0xff as float)); + assert_eq!(from_str_hex("."), Some(0.)); + assert_eq!(from_str_hex(".p1"), Some(0.)); + assert_eq!(from_str_hex(".p-1"), Some(0.)); + assert_eq!(from_str_hex("f."), Some(15.)); + assert_eq!(from_str_hex(".f"), Some(0.9375)); + assert_eq!(from_str_hex("0.f"), Some(0.9375)); + assert_eq!(from_str_hex("-.f"), Some(-0.9375)); + assert_eq!(from_str_hex("-f"), Some(-15.)); + assert_eq!(from_str_hex("inf"), Some(infinity)); + assert_eq!(from_str_hex("+inf"), Some(infinity)); + assert_eq!(from_str_hex("-inf"), Some(neg_infinity)); // note: NaN != NaN, hence this slightly complex test - match from_str_hex(~"NaN") { + match from_str_hex("NaN") { Some(f) => assert!(f.is_NaN()), None => fail!() } // note: -0 == 0, hence these slightly more complex tests - match from_str_hex(~"-0") { + match from_str_hex("-0") { Some(v) if v.is_zero() => assert!(v.is_negative()), _ => fail!() } - match from_str_hex(~"0") { + match from_str_hex("0") { Some(v) if v.is_zero() => assert!(v.is_positive()), _ => fail!() } - assert_eq!(from_str_hex(~"e"), Some(14.)); - assert_eq!(from_str_hex(~"E"), Some(14.)); - assert_eq!(from_str_hex(~"E1"), Some(225.)); - assert_eq!(from_str_hex(~"1e1e1"), Some(123361.)); - assert_eq!(from_str_hex(~"1e1.1"), Some(481.0625)); + assert_eq!(from_str_hex("e"), Some(14.)); + assert_eq!(from_str_hex("E"), Some(14.)); + assert_eq!(from_str_hex("E1"), Some(225.)); + assert_eq!(from_str_hex("1e1e1"), Some(123361.)); + assert_eq!(from_str_hex("1e1.1"), Some(481.0625)); - assert!(from_str_hex(~"").is_none()); - assert!(from_str_hex(~"x").is_none()); - assert!(from_str_hex(~" ").is_none()); - assert!(from_str_hex(~" ").is_none()); - assert!(from_str_hex(~"p").is_none()); - assert!(from_str_hex(~"P").is_none()); - assert!(from_str_hex(~"P1").is_none()); - assert!(from_str_hex(~"1p1p1").is_none()); - assert!(from_str_hex(~"1p1.1").is_none()); - assert!(from_str_hex(~"1p1-1").is_none()); + assert!(from_str_hex("").is_none()); + assert!(from_str_hex("x").is_none()); + assert!(from_str_hex(" ").is_none()); + assert!(from_str_hex(" ").is_none()); + assert!(from_str_hex("p").is_none()); + assert!(from_str_hex("P").is_none()); + assert!(from_str_hex("P1").is_none()); + assert!(from_str_hex("1p1p1").is_none()); + assert!(from_str_hex("1p1.1").is_none()); + assert!(from_str_hex("1p1-1").is_none()); } #[test] @@ -1375,8 +1375,8 @@ mod tests { #[test] pub fn test_from_str_radix() { - assert_eq!(from_str_radix(~"10", 36u), Some(36.)); - assert_eq!(from_str_radix(~"1000.001", 2u), Some(8.125)); + assert_eq!(from_str_radix("10", 36u), Some(36.)); + assert_eq!(from_str_radix("1000.001", 2u), Some(8.125)); } #[test] diff --git a/src/libstd/num/int-template.rs b/src/libstd/num/int-template.rs index 3c31a7d5745..068f553ea6b 100644 --- a/src/libstd/num/int-template.rs +++ b/src/libstd/num/int-template.rs @@ -755,45 +755,45 @@ mod tests { #[test] fn test_from_str() { - assert_eq!(from_str(~"0"), Some(0 as T)); - assert_eq!(from_str(~"3"), Some(3 as T)); - assert_eq!(from_str(~"10"), Some(10 as T)); - assert_eq!(i32::from_str(~"123456789"), Some(123456789 as i32)); - assert_eq!(from_str(~"00100"), Some(100 as T)); + assert_eq!(from_str("0"), Some(0 as T)); + assert_eq!(from_str("3"), Some(3 as T)); + assert_eq!(from_str("10"), Some(10 as T)); + assert_eq!(i32::from_str("123456789"), Some(123456789 as i32)); + assert_eq!(from_str("00100"), Some(100 as T)); - assert_eq!(from_str(~"-1"), Some(-1 as T)); - assert_eq!(from_str(~"-3"), Some(-3 as T)); - assert_eq!(from_str(~"-10"), Some(-10 as T)); - assert_eq!(i32::from_str(~"-123456789"), Some(-123456789 as i32)); - assert_eq!(from_str(~"-00100"), Some(-100 as T)); + assert_eq!(from_str("-1"), Some(-1 as T)); + assert_eq!(from_str("-3"), Some(-3 as T)); + assert_eq!(from_str("-10"), Some(-10 as T)); + assert_eq!(i32::from_str("-123456789"), Some(-123456789 as i32)); + assert_eq!(from_str("-00100"), Some(-100 as T)); - assert!(from_str(~" ").is_none()); - assert!(from_str(~"x").is_none()); + assert!(from_str(" ").is_none()); + assert!(from_str("x").is_none()); } #[test] fn test_parse_bytes() { use str::to_bytes; - assert_eq!(parse_bytes(to_bytes(~"123"), 10u), Some(123 as T)); - assert_eq!(parse_bytes(to_bytes(~"1001"), 2u), Some(9 as T)); - assert_eq!(parse_bytes(to_bytes(~"123"), 8u), Some(83 as T)); - assert_eq!(i32::parse_bytes(to_bytes(~"123"), 16u), Some(291 as i32)); - assert_eq!(i32::parse_bytes(to_bytes(~"ffff"), 16u), Some(65535 as i32)); - assert_eq!(i32::parse_bytes(to_bytes(~"FFFF"), 16u), Some(65535 as i32)); - assert_eq!(parse_bytes(to_bytes(~"z"), 36u), Some(35 as T)); - assert_eq!(parse_bytes(to_bytes(~"Z"), 36u), Some(35 as T)); + assert_eq!(parse_bytes(to_bytes("123"), 10u), Some(123 as T)); + assert_eq!(parse_bytes(to_bytes("1001"), 2u), Some(9 as T)); + assert_eq!(parse_bytes(to_bytes("123"), 8u), Some(83 as T)); + assert_eq!(i32::parse_bytes(to_bytes("123"), 16u), Some(291 as i32)); + assert_eq!(i32::parse_bytes(to_bytes("ffff"), 16u), Some(65535 as i32)); + assert_eq!(i32::parse_bytes(to_bytes("FFFF"), 16u), Some(65535 as i32)); + assert_eq!(parse_bytes(to_bytes("z"), 36u), Some(35 as T)); + assert_eq!(parse_bytes(to_bytes("Z"), 36u), Some(35 as T)); - assert_eq!(parse_bytes(to_bytes(~"-123"), 10u), Some(-123 as T)); - assert_eq!(parse_bytes(to_bytes(~"-1001"), 2u), Some(-9 as T)); - assert_eq!(parse_bytes(to_bytes(~"-123"), 8u), Some(-83 as T)); - assert_eq!(i32::parse_bytes(to_bytes(~"-123"), 16u), Some(-291 as i32)); - assert_eq!(i32::parse_bytes(to_bytes(~"-ffff"), 16u), Some(-65535 as i32)); - assert_eq!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u), Some(-65535 as i32)); - assert_eq!(parse_bytes(to_bytes(~"-z"), 36u), Some(-35 as T)); - assert_eq!(parse_bytes(to_bytes(~"-Z"), 36u), Some(-35 as T)); + assert_eq!(parse_bytes(to_bytes("-123"), 10u), Some(-123 as T)); + assert_eq!(parse_bytes(to_bytes("-1001"), 2u), Some(-9 as T)); + assert_eq!(parse_bytes(to_bytes("-123"), 8u), Some(-83 as T)); + assert_eq!(i32::parse_bytes(to_bytes("-123"), 16u), Some(-291 as i32)); + assert_eq!(i32::parse_bytes(to_bytes("-ffff"), 16u), Some(-65535 as i32)); + assert_eq!(i32::parse_bytes(to_bytes("-FFFF"), 16u), Some(-65535 as i32)); + assert_eq!(parse_bytes(to_bytes("-z"), 36u), Some(-35 as T)); + assert_eq!(parse_bytes(to_bytes("-Z"), 36u), Some(-35 as T)); - assert!(parse_bytes(to_bytes(~"Z"), 35u).is_none()); - assert!(parse_bytes(to_bytes(~"-9"), 2u).is_none()); + assert!(parse_bytes(to_bytes("Z"), 35u).is_none()); + assert!(parse_bytes(to_bytes("-9"), 2u).is_none()); } #[test] @@ -836,36 +836,36 @@ mod tests { #[test] fn test_int_from_str_overflow() { let mut i8_val: i8 = 127_i8; - assert_eq!(i8::from_str(~"127"), Some(i8_val)); - assert!(i8::from_str(~"128").is_none()); + assert_eq!(i8::from_str("127"), Some(i8_val)); + assert!(i8::from_str("128").is_none()); i8_val += 1 as i8; - assert_eq!(i8::from_str(~"-128"), Some(i8_val)); - assert!(i8::from_str(~"-129").is_none()); + assert_eq!(i8::from_str("-128"), Some(i8_val)); + assert!(i8::from_str("-129").is_none()); let mut i16_val: i16 = 32_767_i16; - assert_eq!(i16::from_str(~"32767"), Some(i16_val)); - assert!(i16::from_str(~"32768").is_none()); + assert_eq!(i16::from_str("32767"), Some(i16_val)); + assert!(i16::from_str("32768").is_none()); i16_val += 1 as i16; - assert_eq!(i16::from_str(~"-32768"), Some(i16_val)); - assert!(i16::from_str(~"-32769").is_none()); + assert_eq!(i16::from_str("-32768"), Some(i16_val)); + assert!(i16::from_str("-32769").is_none()); let mut i32_val: i32 = 2_147_483_647_i32; - assert_eq!(i32::from_str(~"2147483647"), Some(i32_val)); - assert!(i32::from_str(~"2147483648").is_none()); + assert_eq!(i32::from_str("2147483647"), Some(i32_val)); + assert!(i32::from_str("2147483648").is_none()); i32_val += 1 as i32; - assert_eq!(i32::from_str(~"-2147483648"), Some(i32_val)); - assert!(i32::from_str(~"-2147483649").is_none()); + assert_eq!(i32::from_str("-2147483648"), Some(i32_val)); + assert!(i32::from_str("-2147483649").is_none()); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert_eq!(i64::from_str(~"9223372036854775807"), Some(i64_val)); - assert!(i64::from_str(~"9223372036854775808").is_none()); + assert_eq!(i64::from_str("9223372036854775807"), Some(i64_val)); + assert!(i64::from_str("9223372036854775808").is_none()); i64_val += 1 as i64; - assert_eq!(i64::from_str(~"-9223372036854775808"), Some(i64_val)); - assert!(i64::from_str(~"-9223372036854775809").is_none()); + assert_eq!(i64::from_str("-9223372036854775808"), Some(i64_val)); + assert!(i64::from_str("-9223372036854775809").is_none()); } #[test] diff --git a/src/libstd/num/uint-template.rs b/src/libstd/num/uint-template.rs index 66ff16cbeb1..9784fe24206 100644 --- a/src/libstd/num/uint-template.rs +++ b/src/libstd/num/uint-template.rs @@ -472,29 +472,29 @@ mod tests { #[test] pub fn test_from_str() { - assert_eq!(from_str(~"0"), Some(0u as T)); - assert_eq!(from_str(~"3"), Some(3u as T)); - assert_eq!(from_str(~"10"), Some(10u as T)); - assert_eq!(u32::from_str(~"123456789"), Some(123456789 as u32)); - assert_eq!(from_str(~"00100"), Some(100u as T)); + assert_eq!(from_str("0"), Some(0u as T)); + assert_eq!(from_str("3"), Some(3u as T)); + assert_eq!(from_str("10"), Some(10u as T)); + assert_eq!(u32::from_str("123456789"), Some(123456789 as u32)); + assert_eq!(from_str("00100"), Some(100u as T)); - assert!(from_str(~"").is_none()); - assert!(from_str(~" ").is_none()); - assert!(from_str(~"x").is_none()); + assert!(from_str("").is_none()); + assert!(from_str(" ").is_none()); + assert!(from_str("x").is_none()); } #[test] pub fn test_parse_bytes() { use str::to_bytes; - assert_eq!(parse_bytes(to_bytes(~"123"), 10u), Some(123u as T)); - assert_eq!(parse_bytes(to_bytes(~"1001"), 2u), Some(9u as T)); - assert_eq!(parse_bytes(to_bytes(~"123"), 8u), Some(83u as T)); - assert_eq!(u16::parse_bytes(to_bytes(~"123"), 16u), Some(291u as u16)); - assert_eq!(u16::parse_bytes(to_bytes(~"ffff"), 16u), Some(65535u as u16)); - assert_eq!(parse_bytes(to_bytes(~"z"), 36u), Some(35u as T)); + assert_eq!(parse_bytes(to_bytes("123"), 10u), Some(123u as T)); + assert_eq!(parse_bytes(to_bytes("1001"), 2u), Some(9u as T)); + assert_eq!(parse_bytes(to_bytes("123"), 8u), Some(83u as T)); + assert_eq!(u16::parse_bytes(to_bytes("123"), 16u), Some(291u as u16)); + assert_eq!(u16::parse_bytes(to_bytes("ffff"), 16u), Some(65535u as u16)); + assert_eq!(parse_bytes(to_bytes("z"), 36u), Some(35u as T)); - assert!(parse_bytes(to_bytes(~"Z"), 10u).is_none()); - assert!(parse_bytes(to_bytes(~"_"), 2u).is_none()); + assert!(parse_bytes(to_bytes("Z"), 10u).is_none()); + assert!(parse_bytes(to_bytes("_"), 2u).is_none()); } #[test] @@ -527,36 +527,36 @@ mod tests { #[test] fn test_uint_from_str_overflow() { let mut u8_val: u8 = 255_u8; - assert_eq!(u8::from_str(~"255"), Some(u8_val)); - assert!(u8::from_str(~"256").is_none()); + assert_eq!(u8::from_str("255"), Some(u8_val)); + assert!(u8::from_str("256").is_none()); u8_val += 1 as u8; - assert_eq!(u8::from_str(~"0"), Some(u8_val)); - assert!(u8::from_str(~"-1").is_none()); + assert_eq!(u8::from_str("0"), Some(u8_val)); + assert!(u8::from_str("-1").is_none()); let mut u16_val: u16 = 65_535_u16; - assert_eq!(u16::from_str(~"65535"), Some(u16_val)); - assert!(u16::from_str(~"65536").is_none()); + assert_eq!(u16::from_str("65535"), Some(u16_val)); + assert!(u16::from_str("65536").is_none()); u16_val += 1 as u16; - assert_eq!(u16::from_str(~"0"), Some(u16_val)); - assert!(u16::from_str(~"-1").is_none()); + assert_eq!(u16::from_str("0"), Some(u16_val)); + assert!(u16::from_str("-1").is_none()); let mut u32_val: u32 = 4_294_967_295_u32; - assert_eq!(u32::from_str(~"4294967295"), Some(u32_val)); - assert!(u32::from_str(~"4294967296").is_none()); + assert_eq!(u32::from_str("4294967295"), Some(u32_val)); + assert!(u32::from_str("4294967296").is_none()); u32_val += 1 as u32; - assert_eq!(u32::from_str(~"0"), Some(u32_val)); - assert!(u32::from_str(~"-1").is_none()); + assert_eq!(u32::from_str("0"), Some(u32_val)); + assert!(u32::from_str("-1").is_none()); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert_eq!(u64::from_str(~"18446744073709551615"), Some(u64_val)); - assert!(u64::from_str(~"18446744073709551616").is_none()); + assert_eq!(u64::from_str("18446744073709551615"), Some(u64_val)); + assert!(u64::from_str("18446744073709551616").is_none()); u64_val += 1 as u64; - assert_eq!(u64::from_str(~"0"), Some(u64_val)); - assert!(u64::from_str(~"-1").is_none()); + assert_eq!(u64::from_str("0"), Some(u64_val)); + assert!(u64::from_str("-1").is_none()); } #[test] diff --git a/src/libstd/os.rs b/src/libstd/os.rs index b2a30e50992..a82f1c98916 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1444,14 +1444,14 @@ mod tests { #[test] fn test_setenv() { let n = make_rand_name(); - setenv(n, ~"VALUE"); + setenv(n, "VALUE"); assert_eq!(getenv(n), option::Some(~"VALUE")); } #[test] fn test_unsetenv() { let n = make_rand_name(); - setenv(n, ~"VALUE"); + setenv(n, "VALUE"); unsetenv(n); assert_eq!(getenv(n), option::None); } @@ -1461,10 +1461,10 @@ mod tests { #[ignore] fn test_setenv_overwrite() { let n = make_rand_name(); - setenv(n, ~"1"); - setenv(n, ~"2"); + setenv(n, "1"); + setenv(n, "2"); assert_eq!(getenv(n), option::Some(~"2")); - setenv(n, ~""); + setenv(n, ""); assert_eq!(getenv(n), option::Some(~"")); } @@ -1515,7 +1515,7 @@ mod tests { let n = make_rand_name(); let mut e = env(); - setenv(n, ~"VALUE"); + setenv(n, "VALUE"); assert!(!vec::contains(e, &(copy n, ~"VALUE"))); e = env(); @@ -1526,7 +1526,7 @@ mod tests { fn test() { assert!((!Path("test-path").is_absolute)); - debug!(~"Current working directory: " + getcwd().to_str()); + debug!("Current working directory: %s", getcwd().to_str()); debug!(make_absolute(&Path("test-path"))); debug!(make_absolute(&Path("/usr/bin"))); @@ -1535,43 +1535,43 @@ mod tests { #[test] #[cfg(unix)] fn homedir() { - let oldhome = getenv(~"HOME"); + let oldhome = getenv("HOME"); - setenv(~"HOME", ~"/home/MountainView"); + setenv("HOME", "/home/MountainView"); assert_eq!(os::homedir(), Some(Path("/home/MountainView"))); - setenv(~"HOME", ~""); + setenv("HOME", ""); assert!(os::homedir().is_none()); - for oldhome.each |s| { setenv(~"HOME", *s) } + for oldhome.each |s| { setenv("HOME", *s) } } #[test] #[cfg(windows)] fn homedir() { - let oldhome = getenv(~"HOME"); - let olduserprofile = getenv(~"USERPROFILE"); + let oldhome = getenv("HOME"); + let olduserprofile = getenv("USERPROFILE"); - setenv(~"HOME", ~""); - setenv(~"USERPROFILE", ~""); + setenv("HOME", ""); + setenv("USERPROFILE", ""); assert!(os::homedir().is_none()); - setenv(~"HOME", ~"/home/MountainView"); + setenv("HOME", "/home/MountainView"); assert_eq!(os::homedir(), Some(Path("/home/MountainView"))); - setenv(~"HOME", ~""); + setenv("HOME", ""); - setenv(~"USERPROFILE", ~"/home/MountainView"); + setenv("USERPROFILE", "/home/MountainView"); assert_eq!(os::homedir(), Some(Path("/home/MountainView"))); - setenv(~"HOME", ~"/home/MountainView"); - setenv(~"USERPROFILE", ~"/home/PaloAlto"); + setenv("HOME", "/home/MountainView"); + setenv("USERPROFILE", "/home/PaloAlto"); assert_eq!(os::homedir(), Some(Path("/home/MountainView"))); - oldhome.each(|s| {setenv(~"HOME", *s);true}); - olduserprofile.each(|s| {setenv(~"USERPROFILE", *s);true}); + oldhome.each(|s| { setenv("HOME", *s); true }); + olduserprofile.each(|s| { setenv("USERPROFILE", *s); true }); } #[test] @@ -1646,7 +1646,7 @@ mod tests { fail!("%s doesn't exist", in.to_str()); } assert!((rs)); - let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); + let rslt = run::run_program("diff", [in.to_str(), out.to_str()]); assert_eq!(rslt, 0); assert_eq!(out.get_mode(), in_mode); assert!((remove_file(&in))); diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 84dd7d187e4..09d0a38e16d 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -988,10 +988,10 @@ mod tests { #[test] fn test_choose_weighted() { let mut r = rng(); - assert!(r.choose_weighted(~[ + assert!(r.choose_weighted([ Weighted { weight: 1u, item: 42 }, ]) == 42); - assert!(r.choose_weighted(~[ + assert!(r.choose_weighted([ Weighted { weight: 0u, item: 42 }, Weighted { weight: 1u, item: 43 }, ]) == 43); @@ -1000,10 +1000,10 @@ mod tests { #[test] fn test_choose_weighted_option() { let mut r = rng(); - assert!(r.choose_weighted_option(~[ + assert!(r.choose_weighted_option([ Weighted { weight: 1u, item: 42 }, ]) == Some(42)); - assert!(r.choose_weighted_option(~[ + assert!(r.choose_weighted_option([ Weighted { weight: 0u, item: 42 }, Weighted { weight: 1u, item: 43 }, ]) == Some(43)); @@ -1015,8 +1015,8 @@ mod tests { fn test_weighted_vec() { let mut r = rng(); let empty: ~[int] = ~[]; - assert_eq!(r.weighted_vec(~[]), empty); - assert!(r.weighted_vec(~[ + assert_eq!(r.weighted_vec([]), empty); + assert!(r.weighted_vec([ Weighted { weight: 0u, item: 3u }, Weighted { weight: 1u, item: 2u }, Weighted { weight: 2u, item: 1u }, @@ -1027,15 +1027,15 @@ mod tests { fn test_shuffle() { let mut r = rng(); let empty: ~[int] = ~[]; - assert_eq!(r.shuffle(~[]), empty); - assert_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); + assert_eq!(r.shuffle([]), empty); + assert_eq!(r.shuffle([1, 1, 1]), ~[1, 1, 1]); } #[test] fn test_task_rng() { let mut r = task_rng(); r.gen::(); - assert_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); + assert_eq!(r.shuffle([1, 1, 1]), ~[1, 1, 1]); assert_eq!(r.gen_uint_range(0u, 1u), 0u); } diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 576a402b709..54db03b6069 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -474,7 +474,7 @@ mod test { #[test] fn oneshot_single_thread_peek_open() { do run_in_newsched_task { - let (port, chan) = oneshot::(); + let (port, _) = oneshot::(); assert!(!port.peek()); } } diff --git a/src/libstd/rt/io/extensions.rs b/src/libstd/rt/io/extensions.rs index ceff2ecd77d..fcbf31e87f2 100644 --- a/src/libstd/rt/io/extensions.rs +++ b/src/libstd/rt/io/extensions.rs @@ -587,12 +587,10 @@ fn extend_sign(val: u64, nbytes: uint) -> i64 { #[cfg(test)] mod test { - use super::{ReaderUtil, ReaderByteConversions, WriterByteConversions}; - use u64; - use i32; + use super::ReaderUtil; use option::{Some, None}; use cell::Cell; - use rt::io::mem::{MemReader, MemWriter}; + use rt::io::mem::MemReader; use rt::io::mock::MockReader; use rt::io::{read_error, placeholder_error}; diff --git a/src/libstd/rt/local.rs b/src/libstd/rt/local.rs index 64a384ddff0..313123c38b5 100644 --- a/src/libstd/rt/local.rs +++ b/src/libstd/rt/local.rs @@ -33,7 +33,7 @@ impl Local for Scheduler { } impl Local for Task { - fn put(value: ~Task) { abort!("unimpl") } + fn put(_value: ~Task) { abort!("unimpl") } fn take() -> ~Task { abort!("unimpl") } fn exists() -> bool { abort!("unimpl") } fn borrow(f: &fn(&mut Task)) { @@ -71,10 +71,10 @@ impl Local for Task { // XXX: This formulation won't work once ~IoFactoryObject is a real trait pointer impl Local for IoFactoryObject { - fn put(value: ~IoFactoryObject) { abort!("unimpl") } + fn put(_value: ~IoFactoryObject) { abort!("unimpl") } fn take() -> ~IoFactoryObject { abort!("unimpl") } fn exists() -> bool { abort!("unimpl") } - fn borrow(f: &fn(&mut IoFactoryObject)) { abort!("unimpl") } + fn borrow(_f: &fn(&mut IoFactoryObject)) { abort!("unimpl") } unsafe fn unsafe_borrow() -> *mut IoFactoryObject { let sched = Local::unsafe_borrow::(); let io: *mut IoFactoryObject = (*sched).event_loop.io().unwrap(); @@ -115,4 +115,4 @@ mod test { } let _scheduler: ~Scheduler = Local::take(); } -} \ No newline at end of file +} diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs index 50c6a894093..2d9cdaddc84 100644 --- a/src/libstd/rt/sched.rs +++ b/src/libstd/rt/sched.rs @@ -20,7 +20,6 @@ use super::context::Context; use super::task::Task; use rt::local_ptr; use rt::local::Local; -use rt::rtio::IoFactoryObject; /// The Scheduler is responsible for coordinating execution of Coroutines /// on a single thread. When the scheduler is running it is owned by diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 0314137fc7f..cf4967b12b3 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -16,7 +16,6 @@ use prelude::*; use libc::{c_void, uintptr_t}; use cast::transmute; -use super::sched::Scheduler; use rt::local::Local; use super::local_heap::LocalHeap; use rt::logging::StdErrLogger; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 53169554ec5..3dae1291e03 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -2794,31 +2794,31 @@ mod tests { #[test] fn test_len() { - assert_eq!(len(~""), 0u); - assert_eq!(len(~"hello world"), 11u); - assert_eq!(len(~"\x63"), 1u); - assert_eq!(len(~"\xa2"), 2u); - assert_eq!(len(~"\u03c0"), 2u); - assert_eq!(len(~"\u2620"), 3u); - assert_eq!(len(~"\U0001d11e"), 4u); + assert_eq!(len(""), 0u); + assert_eq!(len("hello world"), 11u); + assert_eq!(len("\x63"), 1u); + assert_eq!(len("\xa2"), 2u); + assert_eq!(len("\u03c0"), 2u); + assert_eq!(len("\u2620"), 3u); + assert_eq!(len("\U0001d11e"), 4u); - assert_eq!(char_len(~""), 0u); - assert_eq!(char_len(~"hello world"), 11u); - assert_eq!(char_len(~"\x63"), 1u); - assert_eq!(char_len(~"\xa2"), 1u); - assert_eq!(char_len(~"\u03c0"), 1u); - assert_eq!(char_len(~"\u2620"), 1u); - assert_eq!(char_len(~"\U0001d11e"), 1u); - assert_eq!(char_len(~"ประเทศไทย中华Việt Nam"), 19u); + assert_eq!(char_len(""), 0u); + assert_eq!(char_len("hello world"), 11u); + assert_eq!(char_len("\x63"), 1u); + assert_eq!(char_len("\xa2"), 1u); + assert_eq!(char_len("\u03c0"), 1u); + assert_eq!(char_len("\u2620"), 1u); + assert_eq!(char_len("\U0001d11e"), 1u); + assert_eq!(char_len("ประเทศไทย中华Việt Nam"), 19u); } #[test] fn test_rfind_char() { - assert_eq!(rfind_char(~"hello", 'l'), Some(3u)); - assert_eq!(rfind_char(~"hello", 'o'), Some(4u)); - assert_eq!(rfind_char(~"hello", 'h'), Some(0u)); - assert!(rfind_char(~"hello", 'z').is_none()); - assert_eq!(rfind_char(~"ประเทศไทย中华Việt Nam", '华'), Some(30u)); + assert_eq!(rfind_char("hello", 'l'), Some(3u)); + assert_eq!(rfind_char("hello", 'o'), Some(4u)); + assert_eq!(rfind_char("hello", 'h'), Some(0u)); + assert!(rfind_char("hello", 'z').is_none()); + assert_eq!(rfind_char("ประเทศไทย中华Việt Nam", '华'), Some(30u)); } #[test] @@ -2848,66 +2848,66 @@ mod tests { #[test] fn test_split_char() { fn t(s: &str, c: char, u: &[~str]) { - debug!(~"split_byte: " + s); + debug!("split_byte: %?", s); let mut v = ~[]; for each_split_char(s, c) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"abc.hello.there", '.', ~[~"abc", ~"hello", ~"there"]); - t(~".hello.there", '.', ~[~"", ~"hello", ~"there"]); - t(~"...hello.there.", '.', ~[~"", ~"", ~"", ~"hello", ~"there", ~""]); + t("abc.hello.there", '.', [~"abc", ~"hello", ~"there"]); + t(".hello.there", '.', [~"", ~"hello", ~"there"]); + t("...hello.there.", '.', [~"", ~"", ~"", ~"hello", ~"there", ~""]); - t(~"", 'z', ~[~""]); - t(~"z", 'z', ~[~"",~""]); - t(~"ok", 'z', ~[~"ok"]); + t("", 'z', [~""]); + t("z", 'z', [~"",~""]); + t("ok", 'z', [~"ok"]); } #[test] fn test_split_char_2() { fn t(s: &str, c: char, u: &[~str]) { - debug!(~"split_byte: " + s); + debug!("split_byte: %?", s); let mut v = ~[]; for each_split_char(s, c) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); assert!(vec::all2(v, u, |a,b| a == b)); } - let data = ~"ประเทศไทย中华Việt Nam"; - t(data, 'V', ~[~"ประเทศไทย中华", ~"iệt Nam"]); - t(data, 'ท', ~[~"ประเ", ~"ศไ", ~"ย中华Việt Nam"]); + let data = "ประเทศไทย中华Việt Nam"; + t(data, 'V', [~"ประเทศไทย中华", ~"iệt Nam"]); + t(data, 'ท', [~"ประเ", ~"ศไ", ~"ย中华Việt Nam"]); } #[test] fn test_splitn_char() { fn t(s: &str, c: char, n: uint, u: &[~str]) { - debug!(~"splitn_byte: " + s); + debug!("splitn_byte: %?", s); let mut v = ~[]; for each_splitn_char(s, c, n) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); debug!("comparing vs. %?", u); assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"abc.hello.there", '.', 0u, ~[~"abc.hello.there"]); - t(~"abc.hello.there", '.', 1u, ~[~"abc", ~"hello.there"]); - t(~"abc.hello.there", '.', 2u, ~[~"abc", ~"hello", ~"there"]); - t(~"abc.hello.there", '.', 3u, ~[~"abc", ~"hello", ~"there"]); - t(~".hello.there", '.', 0u, ~[~".hello.there"]); - t(~".hello.there", '.', 1u, ~[~"", ~"hello.there"]); - t(~"...hello.there.", '.', 3u, ~[~"", ~"", ~"", ~"hello.there."]); - t(~"...hello.there.", '.', 5u, ~[~"", ~"", ~"", ~"hello", ~"there", ~""]); + t("abc.hello.there", '.', 0u, [~"abc.hello.there"]); + t("abc.hello.there", '.', 1u, [~"abc", ~"hello.there"]); + t("abc.hello.there", '.', 2u, [~"abc", ~"hello", ~"there"]); + t("abc.hello.there", '.', 3u, [~"abc", ~"hello", ~"there"]); + t(".hello.there", '.', 0u, [~".hello.there"]); + t(".hello.there", '.', 1u, [~"", ~"hello.there"]); + t("...hello.there.", '.', 3u, [~"", ~"", ~"", ~"hello.there."]); + t("...hello.there.", '.', 5u, [~"", ~"", ~"", ~"hello", ~"there", ~""]); - t(~"", 'z', 5u, ~[~""]); - t(~"z", 'z', 5u, ~[~"",~""]); - t(~"ok", 'z', 5u, ~[~"ok"]); - t(~"z", 'z', 0u, ~[~"z"]); - t(~"w.x.y", '.', 0u, ~[~"w.x.y"]); - t(~"w.x.y", '.', 1u, ~[~"w",~"x.y"]); + t("", 'z', 5u, [~""]); + t("z", 'z', 5u, [~"",~""]); + t("ok", 'z', 5u, [~"ok"]); + t("z", 'z', 0u, [~"z"]); + t("w.x.y", '.', 0u, [~"w.x.y"]); + t("w.x.y", '.', 1u, [~"w",~"x.y"]); } #[test] - fn test_splitn_char_2 () { + fn test_splitn_char_2() { fn t(s: &str, c: char, n: uint, u: &[~str]) { - debug!(~"splitn_byte: " + s); + debug!("splitn_byte: %?", s); let mut v = ~[]; for each_splitn_char(s, c, n) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); @@ -2915,60 +2915,59 @@ mod tests { assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"ประเทศไทย中华Việt Nam", '华', 1u, ~[~"ประเทศไทย中", ~"Việt Nam"]); - t(~"zzXXXzYYYzWWWz", 'z', 3u, ~[~"", ~"", ~"XXX", ~"YYYzWWWz"]); - t(~"z", 'z', 5u, ~[~"",~""]); - t(~"", 'z', 5u, ~[~""]); - t(~"ok", 'z', 5u, ~[~"ok"]); + t("ประเทศไทย中华Việt Nam", '华', 1u, [~"ประเทศไทย中", ~"Việt Nam"]); + t("zzXXXzYYYzWWWz", 'z', 3u, [~"", ~"", ~"XXX", ~"YYYzWWWz"]); + t("z", 'z', 5u, [~"",~""]); + t("", 'z', 5u, [~""]); + t("ok", 'z', 5u, [~"ok"]); } - #[test] fn test_splitn_char_3() { fn t(s: &str, c: char, n: uint, u: &[~str]) { - debug!(~"splitn_byte: " + s); + debug!("splitn_byte: %?", s); let mut v = ~[]; for each_splitn_char(s, c, n) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); debug!("comparing vs. %?", u); assert!(vec::all2(v, u, |a,b| a == b)); } - let data = ~"ประเทศไทย中华Việt Nam"; - t(data, 'V', 1u, ~[~"ประเทศไทย中华", ~"iệt Nam"]); - t(data, 'ท', 1u, ~[~"ประเ", ~"ศไทย中华Việt Nam"]); + let data = "ประเทศไทย中华Việt Nam"; + t(data, 'V', 1u, [~"ประเทศไทย中华", ~"iệt Nam"]); + t(data, 'ท', 1u, [~"ประเ", ~"ศไทย中华Việt Nam"]); } #[test] fn test_split_char_no_trailing() { fn t(s: &str, c: char, u: &[~str]) { - debug!(~"split_byte: " + s); + debug!("split_byte: %?", s); let mut v = ~[]; for each_split_char_no_trailing(s, c) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"abc.hello.there", '.', ~[~"abc", ~"hello", ~"there"]); - t(~".hello.there", '.', ~[~"", ~"hello", ~"there"]); - t(~"...hello.there.", '.', ~[~"", ~"", ~"", ~"hello", ~"there"]); + t("abc.hello.there", '.', [~"abc", ~"hello", ~"there"]); + t(".hello.there", '.', [~"", ~"hello", ~"there"]); + t("...hello.there.", '.', [~"", ~"", ~"", ~"hello", ~"there"]); - t(~"...hello.there.", '.', ~[~"", ~"", ~"", ~"hello", ~"there"]); - t(~"", 'z', ~[]); - t(~"z", 'z', ~[~""]); - t(~"ok", 'z', ~[~"ok"]); + t("...hello.there.", '.', [~"", ~"", ~"", ~"hello", ~"there"]); + t("", 'z', []); + t("z", 'z', [~""]); + t("ok", 'z', [~"ok"]); } #[test] fn test_split_char_no_trailing_2() { fn t(s: &str, c: char, u: &[~str]) { - debug!(~"split_byte: " + s); + debug!("split_byte: %?", s); let mut v = ~[]; for each_split_char_no_trailing(s, c) |s| { v.push(s.to_owned()) } debug!("split_byte to: %?", v); assert!(vec::all2(v, u, |a,b| a == b)); } - let data = ~"ประเทศไทย中华Việt Nam"; - t(data, 'V', ~[~"ประเทศไทย中华", ~"iệt Nam"]); - t(data, 'ท', ~[~"ประเ", ~"ศไ", ~"ย中华Việt Nam"]); + let data = "ประเทศไทย中华Việt Nam"; + t(data, 'V', [~"ประเทศไทย中华", ~"iệt Nam"]); + t(data, 'ท', [~"ประเ", ~"ศไ", ~"ย中华Việt Nam"]); } #[test] @@ -2978,20 +2977,20 @@ mod tests { for each_split_str(s, sep) |s| { v.push(s.to_owned()) } assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"--1233345--", ~"12345", ~[~"--1233345--"]); - t(~"abc::hello::there", ~"::", ~[~"abc", ~"hello", ~"there"]); - t(~"::hello::there", ~"::", ~[~"", ~"hello", ~"there"]); - t(~"hello::there::", ~"::", ~[~"hello", ~"there", ~""]); - t(~"::hello::there::", ~"::", ~[~"", ~"hello", ~"there", ~""]); - t(~"ประเทศไทย中华Việt Nam", ~"中华", ~[~"ประเทศไทย", ~"Việt Nam"]); - t(~"zzXXXzzYYYzz", ~"zz", ~[~"", ~"XXX", ~"YYY", ~""]); - t(~"zzXXXzYYYz", ~"XXX", ~[~"zz", ~"zYYYz"]); - t(~".XXX.YYY.", ~".", ~[~"", ~"XXX", ~"YYY", ~""]); - t(~"", ~".", ~[~""]); - t(~"zz", ~"zz", ~[~"",~""]); - t(~"ok", ~"z", ~[~"ok"]); - t(~"zzz", ~"zz", ~[~"",~"z"]); - t(~"zzzzz", ~"zz", ~[~"",~"",~"z"]); + t("--1233345--", "12345", [~"--1233345--"]); + t("abc::hello::there", "::", [~"abc", ~"hello", ~"there"]); + t("::hello::there", "::", [~"", ~"hello", ~"there"]); + t("hello::there::", "::", [~"hello", ~"there", ~""]); + t("::hello::there::", "::", [~"", ~"hello", ~"there", ~""]); + t("ประเทศไทย中华Việt Nam", "中华", [~"ประเทศไทย", ~"Việt Nam"]); + t("zzXXXzzYYYzz", "zz", [~"", ~"XXX", ~"YYY", ~""]); + t("zzXXXzYYYz", "XXX", [~"zz", ~"zYYYz"]); + t(".XXX.YYY.", ".", [~"", ~"XXX", ~"YYY", ~""]); + t("", ".", [~""]); + t("zz", "zz", [~"",~""]); + t("ok", "z", [~"ok"]); + t("zzz", "zz", [~"",~"z"]); + t("zzzzz", "zz", [~"",~"",~"z"]); } @@ -3003,12 +3002,12 @@ mod tests { assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"ประเทศไทย中华Việt Nam", |cc| cc == '华', ~[~"ประเทศไทย中", ~"Việt Nam"]); - t(~"zzXXXzYYYz", char::is_lowercase, ~[~"", ~"", ~"XXX", ~"YYY", ~""]); - t(~"zzXXXzYYYz", char::is_uppercase, ~[~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"]); - t(~"z", |cc| cc == 'z', ~[~"",~""]); - t(~"", |cc| cc == 'z', ~[~""]); - t(~"ok", |cc| cc == 'z', ~[~"ok"]); + t("ประเทศไทย中华Việt Nam", |cc| cc == '华', [~"ประเทศไทย中", ~"Việt Nam"]); + t("zzXXXzYYYz", char::is_lowercase, [~"", ~"", ~"XXX", ~"YYY", ~""]); + t("zzXXXzYYYz", char::is_uppercase, [~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"]); + t("z", |cc| cc == 'z', [~"",~""]); + t("", |cc| cc == 'z', [~""]); + t("ok", |cc| cc == 'z', [~"ok"]); } #[test] @@ -3019,18 +3018,18 @@ mod tests { assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"ประเทศไทย中华Việt Nam", |cc| cc == '华', ~[~"ประเทศไทย中", ~"Việt Nam"]); - t(~"zzXXXzYYYz", char::is_lowercase, ~[~"", ~"", ~"XXX", ~"YYY"]); - t(~"zzXXXzYYYz", char::is_uppercase, ~[~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"]); - t(~"z", |cc| cc == 'z', ~[~""]); - t(~"", |cc| cc == 'z', ~[]); - t(~"ok", |cc| cc == 'z', ~[~"ok"]); + t("ประเทศไทย中华Việt Nam", |cc| cc == '华', [~"ประเทศไทย中", ~"Việt Nam"]); + t("zzXXXzYYYz", char::is_lowercase, [~"", ~"", ~"XXX", ~"YYY"]); + t("zzXXXzYYYz", char::is_uppercase, [~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"]); + t("z", |cc| cc == 'z', [~""]); + t("", |cc| cc == 'z', []); + t("ok", |cc| cc == 'z', [~"ok"]); } #[test] fn test_lines() { - let lf = ~"\nMary had a little lamb\nLittle lamb\n"; - let crlf = ~"\r\nMary had a little lamb\r\nLittle lamb\r\n"; + let lf = "\nMary had a little lamb\nLittle lamb\n"; + let crlf = "\r\nMary had a little lamb\r\nLittle lamb\r\n"; fn t(s: &str, f: &fn(&str, &fn(&str) -> bool) -> bool, u: &[~str]) { let mut v = ~[]; @@ -3038,30 +3037,30 @@ mod tests { assert!(vec::all2(v, u, |a,b| a == b)); } - t(lf, each_line ,~[~"", ~"Mary had a little lamb", ~"Little lamb"]); - t(lf, each_line_any, ~[~"", ~"Mary had a little lamb", ~"Little lamb"]); - t(crlf, each_line, ~[~"\r", ~"Mary had a little lamb\r", ~"Little lamb\r"]); - t(crlf, each_line_any, ~[~"", ~"Mary had a little lamb", ~"Little lamb"]); - t(~"", each_line, ~[]); - t(~"", each_line_any, ~[]); - t(~"\n", each_line, ~[~""]); - t(~"\n", each_line_any, ~[~""]); - t(~"banana", each_line, ~[~"banana"]); - t(~"banana", each_line_any, ~[~"banana"]); + t(lf, each_line, [~"", ~"Mary had a little lamb", ~"Little lamb"]); + t(lf, each_line_any, [~"", ~"Mary had a little lamb", ~"Little lamb"]); + t(crlf, each_line, [~"\r", ~"Mary had a little lamb\r", ~"Little lamb\r"]); + t(crlf, each_line_any, [~"", ~"Mary had a little lamb", ~"Little lamb"]); + t("", each_line, []); + t("", each_line_any, []); + t("\n", each_line, [~""]); + t("\n", each_line_any, [~""]); + t("banana", each_line, [~"banana"]); + t("banana", each_line_any, [~"banana"]); } #[test] - fn test_words () { + fn test_words() { fn t(s: &str, f: &fn(&str, &fn(&str) -> bool) -> bool, u: &[~str]) { let mut v = ~[]; for f(s) |s| { v.push(s.to_owned()) } assert!(vec::all2(v, u, |a,b| a == b)); } - let data = ~"\nMary had a little lamb\nLittle lamb\n"; + let data = "\nMary had a little lamb\nLittle lamb\n"; - t(data, each_word, ~[~"Mary",~"had",~"a",~"little",~"lamb",~"Little",~"lamb"]); - t(~"ok", each_word, ~[~"ok"]); - t(~"", each_word, ~[]); + t(data, each_word, [~"Mary",~"had",~"a",~"little",~"lamb",~"Little",~"lamb"]); + t("ok", each_word, [~"ok"]); + t("", each_word, []); } #[test] @@ -3071,53 +3070,53 @@ mod tests { for each_split_within(s, i) |s| { v.push(s.to_owned()) } assert!(vec::all2(v, u, |a,b| a == b)); } - t(~"", 0, ~[]); - t(~"", 15, ~[]); - t(~"hello", 15, ~[~"hello"]); - t(~"\nMary had a little lamb\nLittle lamb\n", 15, - ~[~"Mary had a", ~"little lamb", ~"Little lamb"]); + t("", 0, []); + t("", 15, []); + t("hello", 15, [~"hello"]); + t("\nMary had a little lamb\nLittle lamb\n", 15, + [~"Mary had a", ~"little lamb", ~"Little lamb"]); } #[test] fn test_find_str() { // byte positions - assert!(find_str(~"banana", ~"apple pie").is_none()); - assert_eq!(find_str(~"", ~""), Some(0u)); + assert!(find_str("banana", "apple pie").is_none()); + assert_eq!(find_str("", ""), Some(0u)); - let data = ~"ประเทศไทย中华Việt Nam"; - assert_eq!(find_str(data, ~""), Some(0u)); - assert_eq!(find_str(data, ~"ประเ"), Some( 0u)); - assert_eq!(find_str(data, ~"ะเ"), Some( 6u)); - assert_eq!(find_str(data, ~"中华"), Some(27u)); - assert!(find_str(data, ~"ไท华").is_none()); + let data = "ประเทศไทย中华Việt Nam"; + assert_eq!(find_str(data, ""), Some(0u)); + assert_eq!(find_str(data, "ประเ"), Some( 0u)); + assert_eq!(find_str(data, "ะเ"), Some( 6u)); + assert_eq!(find_str(data, "中华"), Some(27u)); + assert!(find_str(data, "ไท华").is_none()); } #[test] fn test_find_str_between() { // byte positions - assert_eq!(find_str_between(~"", ~"", 0u, 0u), Some(0u)); + assert_eq!(find_str_between("", "", 0u, 0u), Some(0u)); - let data = ~"abcabc"; - assert_eq!(find_str_between(data, ~"ab", 0u, 6u), Some(0u)); - assert_eq!(find_str_between(data, ~"ab", 2u, 6u), Some(3u)); - assert!(find_str_between(data, ~"ab", 2u, 4u).is_none()); + let data = "abcabc"; + assert_eq!(find_str_between(data, "ab", 0u, 6u), Some(0u)); + assert_eq!(find_str_between(data, "ab", 2u, 6u), Some(3u)); + assert!(find_str_between(data, "ab", 2u, 4u).is_none()); let mut data = ~"ประเทศไทย中华Việt Nam"; data = data + data; - assert_eq!(find_str_between(data, ~"", 0u, 43u), Some(0u)); - assert_eq!(find_str_between(data, ~"", 6u, 43u), Some(6u)); + assert_eq!(find_str_between(data, "", 0u, 43u), Some(0u)); + assert_eq!(find_str_between(data, "", 6u, 43u), Some(6u)); - assert_eq!(find_str_between(data, ~"ประ", 0u, 43u), Some( 0u)); - assert_eq!(find_str_between(data, ~"ทศไ", 0u, 43u), Some(12u)); - assert_eq!(find_str_between(data, ~"ย中", 0u, 43u), Some(24u)); - assert_eq!(find_str_between(data, ~"iệt", 0u, 43u), Some(34u)); - assert_eq!(find_str_between(data, ~"Nam", 0u, 43u), Some(40u)); + assert_eq!(find_str_between(data, "ประ", 0u, 43u), Some( 0u)); + assert_eq!(find_str_between(data, "ทศไ", 0u, 43u), Some(12u)); + assert_eq!(find_str_between(data, "ย中", 0u, 43u), Some(24u)); + assert_eq!(find_str_between(data, "iệt", 0u, 43u), Some(34u)); + assert_eq!(find_str_between(data, "Nam", 0u, 43u), Some(40u)); - assert_eq!(find_str_between(data, ~"ประ", 43u, 86u), Some(43u)); - assert_eq!(find_str_between(data, ~"ทศไ", 43u, 86u), Some(55u)); - assert_eq!(find_str_between(data, ~"ย中", 43u, 86u), Some(67u)); - assert_eq!(find_str_between(data, ~"iệt", 43u, 86u), Some(77u)); - assert_eq!(find_str_between(data, ~"Nam", 43u, 86u), Some(83u)); + assert_eq!(find_str_between(data, "ประ", 43u, 86u), Some(43u)); + assert_eq!(find_str_between(data, "ทศไ", 43u, 86u), Some(55u)); + assert_eq!(find_str_between(data, "ย中", 43u, 86u), Some(67u)); + assert_eq!(find_str_between(data, "iệt", 43u, 86u), Some(77u)); + assert_eq!(find_str_between(data, "Nam", 43u, 86u), Some(83u)); } #[test] @@ -3135,10 +3134,10 @@ mod tests { fn t(v: &[~str], s: &str) { assert_eq!(concat(v), s.to_str()); } - t(~[~"you", ~"know", ~"I'm", ~"no", ~"good"], ~"youknowI'mnogood"); - let v: ~[~str] = ~[]; - t(v, ~""); - t(~[~"hi"], ~"hi"); + t([~"you", ~"know", ~"I'm", ~"no", ~"good"], "youknowI'mnogood"); + let v: &[~str] = []; + t(v, ""); + t([~"hi"], "hi"); } #[test] @@ -3146,11 +3145,11 @@ mod tests { fn t(v: &[~str], sep: &str, s: &str) { assert_eq!(connect(v, sep), s.to_str()); } - t(~[~"you", ~"know", ~"I'm", ~"no", ~"good"], - ~" ", ~"you know I'm no good"); - let v: ~[~str] = ~[]; - t(v, ~" ", ~""); - t(~[~"hi"], ~" ", ~"hi"); + t([~"you", ~"know", ~"I'm", ~"no", ~"good"], + " ", "you know I'm no good"); + let v: &[~str] = ~[]; + t(v, " ", ""); + t([~"hi"], " ", "hi"); } #[test] @@ -3166,11 +3165,11 @@ mod tests { #[test] fn test_repeat() { - assert_eq!(repeat(~"x", 4), ~"xxxx"); - assert_eq!(repeat(~"hi", 4), ~"hihihihi"); - assert_eq!(repeat(~"ไท华", 3), ~"ไท华ไท华ไท华"); - assert_eq!(repeat(~"", 4), ~""); - assert_eq!(repeat(~"hi", 0), ~""); + assert_eq!(repeat("x", 4), ~"xxxx"); + assert_eq!(repeat("hi", 4), ~"hihihihi"); + assert_eq!(repeat("ไท华", 3), ~"ไท华ไท华ไท华"); + assert_eq!(repeat("", 4), ~""); + assert_eq!(repeat("hi", 0), ~""); } #[test] @@ -3197,38 +3196,38 @@ mod tests { #[test] fn test_starts_with() { - assert!((starts_with(~"", ~""))); - assert!((starts_with(~"abc", ~""))); - assert!((starts_with(~"abc", ~"a"))); - assert!((!starts_with(~"a", ~"abc"))); - assert!((!starts_with(~"", ~"abc"))); + assert!((starts_with("", ""))); + assert!((starts_with("abc", ""))); + assert!((starts_with("abc", "a"))); + assert!((!starts_with("a", "abc"))); + assert!((!starts_with("", "abc"))); } #[test] fn test_ends_with() { - assert!((ends_with(~"", ~""))); - assert!((ends_with(~"abc", ~""))); - assert!((ends_with(~"abc", ~"c"))); - assert!((!ends_with(~"a", ~"abc"))); - assert!((!ends_with(~"", ~"abc"))); + assert!((ends_with("", ""))); + assert!((ends_with("abc", ""))); + assert!((ends_with("abc", "c"))); + assert!((!ends_with("a", "abc"))); + assert!((!ends_with("", "abc"))); } #[test] fn test_is_empty() { - assert!((is_empty(~""))); - assert!((!is_empty(~"a"))); + assert!((is_empty(""))); + assert!((!is_empty("a"))); } #[test] fn test_replace() { - let a = ~"a"; - assert_eq!(replace(~"", a, ~"b"), ~""); - assert_eq!(replace(~"a", a, ~"b"), ~"b"); - assert_eq!(replace(~"ab", a, ~"b"), ~"bb"); - let test = ~"test"; - assert!(replace(~" test test ", test, ~"toast") == + let a = "a"; + assert_eq!(replace("", a, "b"), ~""); + assert_eq!(replace("a", a, "b"), ~"b"); + assert_eq!(replace("ab", a, "b"), ~"bb"); + let test = "test"; + assert!(replace(" test test ", test, "toast") == ~" toast toast "); - assert_eq!(replace(~" test test ", test, ~""), ~" "); + assert_eq!(replace(" test test ", test, ""), ~" "); } #[test] @@ -3338,32 +3337,26 @@ mod tests { #[test] fn test_trim_left_chars() { - assert!(trim_left_chars(" *** foo *** ", ~[]) == - " *** foo *** "); - assert!(trim_left_chars(" *** foo *** ", ~['*', ' ']) == - "foo *** "); - assert_eq!(trim_left_chars(" *** *** ", ~['*', ' ']), ""); - assert!(trim_left_chars("foo *** ", ~['*', ' ']) == - "foo *** "); + assert!(trim_left_chars(" *** foo *** ", []) == " *** foo *** "); + assert!(trim_left_chars(" *** foo *** ", ['*', ' ']) == "foo *** "); + assert_eq!(trim_left_chars(" *** *** ", ['*', ' ']), ""); + assert!(trim_left_chars("foo *** ", ['*', ' ']) == "foo *** "); } #[test] fn test_trim_right_chars() { - assert!(trim_right_chars(" *** foo *** ", ~[]) == - " *** foo *** "); - assert!(trim_right_chars(" *** foo *** ", ~['*', ' ']) == - " *** foo"); - assert_eq!(trim_right_chars(" *** *** ", ~['*', ' ']), ""); - assert!(trim_right_chars(" *** foo", ~['*', ' ']) == - " *** foo"); + assert!(trim_right_chars(" *** foo *** ", []) == " *** foo *** "); + assert!(trim_right_chars(" *** foo *** ", ['*', ' ']) == " *** foo"); + assert_eq!(trim_right_chars(" *** *** ", ['*', ' ']), ""); + assert!(trim_right_chars(" *** foo", ['*', ' ']) == " *** foo"); } #[test] fn test_trim_chars() { - assert_eq!(trim_chars(" *** foo *** ", ~[]), " *** foo *** "); - assert_eq!(trim_chars(" *** foo *** ", ~['*', ' ']), "foo"); - assert_eq!(trim_chars(" *** *** ", ~['*', ' ']), ""); - assert_eq!(trim_chars("foo", ~['*', ' ']), "foo"); + assert_eq!(trim_chars(" *** foo *** ", []), " *** foo *** "); + assert_eq!(trim_chars(" *** foo *** ", ['*', ' ']), "foo"); + assert_eq!(trim_chars(" *** *** ", ['*', ' ']), ""); + assert_eq!(trim_chars("foo", ['*', ' ']), "foo"); } #[test] @@ -3398,11 +3391,11 @@ mod tests { #[test] fn test_is_whitespace() { - assert!((is_whitespace(~""))); - assert!((is_whitespace(~" "))); - assert!((is_whitespace(~"\u2009"))); // Thin space - assert!((is_whitespace(~" \n\t "))); - assert!((!is_whitespace(~" _ "))); + assert!(is_whitespace("")); + assert!(is_whitespace(" ")); + assert!(is_whitespace("\u2009")); // Thin space + assert!(is_whitespace(" \n\t ")); + assert!(!is_whitespace(" _ ")); } #[test] @@ -3543,7 +3536,7 @@ mod tests { #[test] fn test_as_buf() { - let a = ~"Abcdefg"; + let a = "Abcdefg"; let b = as_buf(a, |buf, _l| { assert_eq!(unsafe { *buf }, 65u8); 100 @@ -3553,7 +3546,7 @@ mod tests { #[test] fn test_as_buf_small() { - let a = ~"A"; + let a = "A"; let b = as_buf(a, |buf, _l| { assert_eq!(unsafe { *buf }, 65u8); 100 @@ -3631,32 +3624,32 @@ mod tests { #[test] fn test_contains() { - assert!(contains(~"abcde", ~"bcd")); - assert!(contains(~"abcde", ~"abcd")); - assert!(contains(~"abcde", ~"bcde")); - assert!(contains(~"abcde", ~"")); - assert!(contains(~"", ~"")); - assert!(!contains(~"abcde", ~"def")); - assert!(!contains(~"", ~"a")); + assert!(contains("abcde", "bcd")); + assert!(contains("abcde", "abcd")); + assert!(contains("abcde", "bcde")); + assert!(contains("abcde", "")); + assert!(contains("", "")); + assert!(!contains("abcde", "def")); + assert!(!contains("", "a")); let data = ~"ประเทศไทย中华Việt Nam"; - assert!(contains(data, ~"ประเ")); - assert!(contains(data, ~"ะเ")); - assert!(contains(data, ~"中华")); - assert!(!contains(data, ~"ไท华")); + assert!(contains(data, "ประเ")); + assert!(contains(data, "ะเ")); + assert!(contains(data, "中华")); + assert!(!contains(data, "ไท华")); } #[test] fn test_contains_char() { - assert!(contains_char(~"abc", 'b')); - assert!(contains_char(~"a", 'a')); - assert!(!contains_char(~"abc", 'd')); - assert!(!contains_char(~"", 'a')); + assert!(contains_char("abc", 'b')); + assert!(contains_char("a", 'a')); + assert!(!contains_char("abc", 'd')); + assert!(!contains_char("", 'a')); } #[test] fn test_split_char_each() { - let data = ~"\nMary had a little lamb\nLittle lamb\n"; + let data = "\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; @@ -3674,7 +3667,7 @@ mod tests { #[test] fn test_splitn_char_each() { - let data = ~"\nMary had a little lamb\nLittle lamb\n"; + let data = "\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; @@ -3691,7 +3684,7 @@ mod tests { #[test] fn test_words_each() { - let data = ~"\nMary had a little lamb\nLittle lamb\n"; + let data = "\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; @@ -3706,12 +3699,12 @@ mod tests { ii += 1; } - each_word(~"", |_x| fail!()); // should not fail + each_word("", |_x| fail!()); // should not fail } #[test] fn test_lines_each () { - let lf = ~"\nMary had a little lamb\nLittle lamb\n"; + let lf = "\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; @@ -3728,26 +3721,26 @@ mod tests { #[test] fn test_map() { - assert_eq!(~"", map(~"", |c| unsafe {libc::toupper(c as c_char)} as char)); - assert_eq!(~"YMCA", map(~"ymca", |c| unsafe {libc::toupper(c as c_char)} as char)); + assert_eq!(~"", map("", |c| unsafe {libc::toupper(c as c_char)} as char)); + assert_eq!(~"YMCA", map("ymca", |c| unsafe {libc::toupper(c as c_char)} as char)); } #[test] fn test_all() { - assert_eq!(true, all(~"", char::is_uppercase)); - assert_eq!(false, all(~"ymca", char::is_uppercase)); - assert_eq!(true, all(~"YMCA", char::is_uppercase)); - assert_eq!(false, all(~"yMCA", char::is_uppercase)); - assert_eq!(false, all(~"YMCy", char::is_uppercase)); + assert_eq!(true, all("", char::is_uppercase)); + assert_eq!(false, all("ymca", char::is_uppercase)); + assert_eq!(true, all("YMCA", char::is_uppercase)); + assert_eq!(false, all("yMCA", char::is_uppercase)); + assert_eq!(false, all("YMCy", char::is_uppercase)); } #[test] fn test_any() { - assert_eq!(false, any(~"", char::is_uppercase)); - assert_eq!(false, any(~"ymca", char::is_uppercase)); - assert_eq!(true, any(~"YMCA", char::is_uppercase)); - assert_eq!(true, any(~"yMCA", char::is_uppercase)); - assert_eq!(true, any(~"Ymcy", char::is_uppercase)); + assert_eq!(false, any("", char::is_uppercase)); + assert_eq!(false, any("ymca", char::is_uppercase)); + assert_eq!(true, any("YMCA", char::is_uppercase)); + assert_eq!(true, any("yMCA", char::is_uppercase)); + assert_eq!(true, any("Ymcy", char::is_uppercase)); } #[test] @@ -3761,41 +3754,41 @@ mod tests { #[test] fn test_utf16() { let pairs = - ~[(~"𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n", + [(~"𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n", ~[0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16, - 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16, - 0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16, - 0xd800_u16, 0xdf30_u16, 0x000a_u16]), + 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16, + 0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16, + 0xd800_u16, 0xdf30_u16, 0x000a_u16]), (~"𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n", ~[0xd801_u16, 0xdc12_u16, 0xd801_u16, - 0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16, - 0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16, - 0xdc4b_u16, 0x0020_u16, 0xd801_u16, 0xdc0f_u16, - 0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16, - 0x000a_u16]), + 0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16, + 0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16, + 0xdc4b_u16, 0x0020_u16, 0xd801_u16, 0xdc0f_u16, + 0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16, + 0x000a_u16]), (~"𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n", ~[0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16, - 0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16, - 0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16, - 0x00b7_u16, 0xd800_u16, 0xdf0c_u16, 0xd800_u16, - 0xdf04_u16, 0xd800_u16, 0xdf15_u16, 0xd800_u16, - 0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16, - 0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]), + 0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16, + 0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16, + 0x00b7_u16, 0xd800_u16, 0xdf0c_u16, 0xd800_u16, + 0xdf04_u16, 0xd800_u16, 0xdf15_u16, 0xd800_u16, + 0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16, + 0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]), (~"𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n", ~[0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16, - 0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16, - 0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16, - 0x0020_u16, 0xd801_u16, 0xdc95_u16, 0xd801_u16, - 0xdc93_u16, 0x0020_u16, 0xd801_u16, 0xdc88_u16, - 0xd801_u16, 0xdc9a_u16, 0xd801_u16, 0xdc8d_u16, - 0x0020_u16, 0xd801_u16, 0xdc8f_u16, 0xd801_u16, - 0xdc9c_u16, 0xd801_u16, 0xdc92_u16, 0xd801_u16, - 0xdc96_u16, 0xd801_u16, 0xdc86_u16, 0x0020_u16, - 0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16, - 0x000a_u16 ]) ]; + 0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16, + 0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16, + 0x0020_u16, 0xd801_u16, 0xdc95_u16, 0xd801_u16, + 0xdc93_u16, 0x0020_u16, 0xd801_u16, 0xdc88_u16, + 0xd801_u16, 0xdc9a_u16, 0xd801_u16, 0xdc8d_u16, + 0x0020_u16, 0xd801_u16, 0xdc8f_u16, 0xd801_u16, + 0xdc9c_u16, 0xd801_u16, 0xdc92_u16, 0xd801_u16, + 0xdc96_u16, 0xd801_u16, 0xdc86_u16, 0x0020_u16, + 0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16, + 0x000a_u16 ]) ]; for pairs.each |p| { let (s, u) = copy *p; @@ -3972,35 +3965,35 @@ mod tests { #[test] fn test_escape_unicode() { - assert_eq!(escape_unicode(~"abc"), ~"\\x61\\x62\\x63"); - assert_eq!(escape_unicode(~"a c"), ~"\\x61\\x20\\x63"); - assert_eq!(escape_unicode(~"\r\n\t"), ~"\\x0d\\x0a\\x09"); - assert_eq!(escape_unicode(~"'\"\\"), ~"\\x27\\x22\\x5c"); - assert!(escape_unicode(~"\x00\x01\xfe\xff") == + assert_eq!(escape_unicode("abc"), ~"\\x61\\x62\\x63"); + assert_eq!(escape_unicode("a c"), ~"\\x61\\x20\\x63"); + assert_eq!(escape_unicode("\r\n\t"), ~"\\x0d\\x0a\\x09"); + assert_eq!(escape_unicode("'\"\\"), ~"\\x27\\x22\\x5c"); + assert!(escape_unicode("\x00\x01\xfe\xff") == ~"\\x00\\x01\\xfe\\xff"); - assert_eq!(escape_unicode(~"\u0100\uffff"), ~"\\u0100\\uffff"); - assert!(escape_unicode(~"\U00010000\U0010ffff") == + assert_eq!(escape_unicode("\u0100\uffff"), ~"\\u0100\\uffff"); + assert!(escape_unicode("\U00010000\U0010ffff") == ~"\\U00010000\\U0010ffff"); - assert_eq!(escape_unicode(~"ab\ufb00"), ~"\\x61\\x62\\ufb00"); - assert_eq!(escape_unicode(~"\U0001d4ea\r"), ~"\\U0001d4ea\\x0d"); + assert_eq!(escape_unicode("ab\ufb00"), ~"\\x61\\x62\\ufb00"); + assert_eq!(escape_unicode("\U0001d4ea\r"), ~"\\U0001d4ea\\x0d"); } #[test] fn test_escape_default() { - assert_eq!(escape_default(~"abc"), ~"abc"); - assert_eq!(escape_default(~"a c"), ~"a c"); - assert_eq!(escape_default(~"\r\n\t"), ~"\\r\\n\\t"); - assert_eq!(escape_default(~"'\"\\"), ~"\\'\\\"\\\\"); - assert_eq!(escape_default(~"\u0100\uffff"), ~"\\u0100\\uffff"); - assert!(escape_default(~"\U00010000\U0010ffff") == + assert_eq!(escape_default("abc"), ~"abc"); + assert_eq!(escape_default("a c"), ~"a c"); + assert_eq!(escape_default("\r\n\t"), ~"\\r\\n\\t"); + assert_eq!(escape_default("'\"\\"), ~"\\'\\\"\\\\"); + assert_eq!(escape_default("\u0100\uffff"), ~"\\u0100\\uffff"); + assert!(escape_default("\U00010000\U0010ffff") == ~"\\U00010000\\U0010ffff"); - assert_eq!(escape_default(~"ab\ufb00"), ~"ab\\ufb00"); - assert_eq!(escape_default(~"\U0001d4ea\r"), ~"\\U0001d4ea\\r"); + assert_eq!(escape_default("ab\ufb00"), ~"ab\\ufb00"); + assert_eq!(escape_default("\U0001d4ea\r"), ~"\\U0001d4ea\\r"); } #[test] fn test_to_managed() { - assert_eq!((~"abc").to_managed(), @"abc"); + assert_eq!("abc".to_managed(), @"abc"); assert_eq!(slice("abcdef", 1, 5).to_managed(), @"bcde"); } diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index 4e239c4c82c..e48fef01df9 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -228,8 +228,8 @@ mod tests { assert_eq!('`'.to_ascii().to_upper().to_char(), '`'); assert_eq!('{'.to_ascii().to_upper().to_char(), '{'); - assert!(str::all(~"banana", |c| c.is_ascii())); - assert!(! str::all(~"ประเทศไทย中华Việt Nam", |c| c.is_ascii())); + assert!(str::all("banana", |c| c.is_ascii())); + assert!(! str::all("ประเทศไทย中华Việt Nam", |c| c.is_ascii())); } #[test] diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 65f8dab25a5..103489988a3 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2962,8 +2962,8 @@ mod tests { #[test] fn test_is_empty() { - assert!(is_empty::(~[])); - assert!(!is_empty(~[0])); + assert!(is_empty::([])); + assert!(!is_empty([0])); } #[test] @@ -3445,7 +3445,7 @@ mod tests { #[test] fn test_each_empty() { - for each::(~[]) |_v| { + for each::([]) |_v| { fail!(); // should never be executed } } @@ -3453,7 +3453,7 @@ mod tests { #[test] fn test_each_nonempty() { let mut i = 0; - for each(~[1, 2, 3]) |v| { + for each([1, 2, 3]) |v| { i += *v; } assert_eq!(i, 6); @@ -3462,7 +3462,7 @@ mod tests { #[test] fn test_eachi() { let mut i = 0; - for eachi(~[1, 2, 3]) |j, v| { + for eachi([1, 2, 3]) |j, v| { if i == 0 { assert!(*v == 1); } assert_eq!(j + 1u, *v as uint); i += *v; @@ -3481,7 +3481,7 @@ mod tests { #[test] fn test_each_reverse_nonempty() { let mut i = 0; - for each_reverse(~[1, 2, 3]) |v| { + for each_reverse([1, 2, 3]) |v| { if i == 0 { assert!(*v == 3); } i += *v } @@ -3491,7 +3491,7 @@ mod tests { #[test] fn test_eachi_reverse() { let mut i = 0; - for eachi_reverse(~[0, 1, 2]) |j, v| { + for eachi_reverse([0, 1, 2]) |j, v| { if i == 0 { assert!(*v == 2); } assert_eq!(j, *v as uint); i += *v; @@ -3512,48 +3512,48 @@ mod tests { let mut results: ~[~[int]]; results = ~[]; - for each_permutation(~[]) |v| { results.push(to_owned(v)); } + for each_permutation([]) |v| { results.push(to_owned(v)); } assert_eq!(results, ~[~[]]); results = ~[]; - for each_permutation(~[7]) |v| { results.push(to_owned(v)); } + for each_permutation([7]) |v| { results.push(to_owned(v)); } assert_eq!(results, ~[~[7]]); results = ~[]; - for each_permutation(~[1,1]) |v| { results.push(to_owned(v)); } + for each_permutation([1,1]) |v| { results.push(to_owned(v)); } assert_eq!(results, ~[~[1,1],~[1,1]]); results = ~[]; - for each_permutation(~[5,2,0]) |v| { results.push(to_owned(v)); } + for each_permutation([5,2,0]) |v| { results.push(to_owned(v)); } assert!(results == ~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]); } #[test] fn test_any_and_all() { - assert!(any(~[1u, 2u, 3u], is_three)); - assert!(!any(~[0u, 1u, 2u], is_three)); - assert!(any(~[1u, 2u, 3u, 4u, 5u], is_three)); - assert!(!any(~[1u, 2u, 4u, 5u, 6u], is_three)); + assert!(any([1u, 2u, 3u], is_three)); + assert!(!any([0u, 1u, 2u], is_three)); + assert!(any([1u, 2u, 3u, 4u, 5u], is_three)); + assert!(!any([1u, 2u, 4u, 5u, 6u], is_three)); - assert!(all(~[3u, 3u, 3u], is_three)); - assert!(!all(~[3u, 3u, 2u], is_three)); - assert!(all(~[3u, 3u, 3u, 3u, 3u], is_three)); - assert!(!all(~[3u, 3u, 0u, 1u, 2u], is_three)); + assert!(all([3u, 3u, 3u], is_three)); + assert!(!all([3u, 3u, 2u], is_three)); + assert!(all([3u, 3u, 3u, 3u, 3u], is_three)); + assert!(!all([3u, 3u, 0u, 1u, 2u], is_three)); } #[test] fn test_any2_and_all2() { - assert!(any2(~[2u, 4u, 6u], ~[2u, 4u, 6u], is_equal)); - assert!(any2(~[1u, 2u, 3u], ~[4u, 5u, 3u], is_equal)); - assert!(!any2(~[1u, 2u, 3u], ~[4u, 5u, 6u], is_equal)); - assert!(any2(~[2u, 4u, 6u], ~[2u, 4u], is_equal)); + assert!(any2([2u, 4u, 6u], [2u, 4u, 6u], is_equal)); + assert!(any2([1u, 2u, 3u], [4u, 5u, 3u], is_equal)); + assert!(!any2([1u, 2u, 3u], [4u, 5u, 6u], is_equal)); + assert!(any2([2u, 4u, 6u], [2u, 4u], is_equal)); - assert!(all2(~[2u, 4u, 6u], ~[2u, 4u, 6u], is_equal)); - assert!(!all2(~[1u, 2u, 3u], ~[4u, 5u, 3u], is_equal)); - assert!(!all2(~[1u, 2u, 3u], ~[4u, 5u, 6u], is_equal)); - assert!(!all2(~[2u, 4u, 6u], ~[2u, 4u], is_equal)); + assert!(all2([2u, 4u, 6u], [2u, 4u, 6u], is_equal)); + assert!(!all2([1u, 2u, 3u], [4u, 5u, 3u], is_equal)); + assert!(!all2([1u, 2u, 3u], [4u, 5u, 6u], is_equal)); + assert!(!all2([2u, 4u, 6u], [2u, 4u], is_equal)); } #[test] @@ -3576,7 +3576,7 @@ mod tests { #[test] fn test_position_elem() { - assert!(position_elem(~[], &1).is_none()); + assert!(position_elem([], &1).is_none()); let v1 = ~[1, 2, 3, 3, 2, 5]; assert_eq!(position_elem(v1, &1), Some(0u)); @@ -3590,7 +3590,7 @@ mod tests { fn less_than_three(i: &int) -> bool { *i < 3 } fn is_eighteen(i: &int) -> bool { *i == 18 } - assert!(position(~[], less_than_three).is_none()); + assert!(position([], less_than_three).is_none()); let v1 = ~[5, 4, 3, 2, 1]; assert_eq!(position(v1, less_than_three), Some(3u)); @@ -3599,7 +3599,7 @@ mod tests { #[test] fn test_position_between() { - assert!(position_between(~[], 0u, 0u, f).is_none()); + assert!(position_between([], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; @@ -3627,7 +3627,7 @@ mod tests { #[test] fn test_find() { - assert!(find(~[], f).is_none()); + assert!(find([], f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } @@ -3639,7 +3639,7 @@ mod tests { #[test] fn test_find_between() { - assert!(find_between(~[], 0u, 0u, f).is_none()); + assert!(find_between([], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; @@ -3667,7 +3667,7 @@ mod tests { #[test] fn test_rposition() { - assert!(find(~[], f).is_none()); + assert!(find([], f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } @@ -3679,7 +3679,7 @@ mod tests { #[test] fn test_rposition_between() { - assert!(rposition_between(~[], 0u, 0u, f).is_none()); + assert!(rposition_between([], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; @@ -3707,7 +3707,7 @@ mod tests { #[test] fn test_rfind() { - assert!(rfind(~[], f).is_none()); + assert!(rfind([], f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } @@ -3719,7 +3719,7 @@ mod tests { #[test] fn test_rfind_between() { - assert!(rfind_between(~[], 0u, 0u, f).is_none()); + assert!(rfind_between([], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; @@ -3798,14 +3798,14 @@ mod tests { reverse(v); assert_eq!(v[0], 20); assert_eq!(v[1], 10); - let v2 = reversed::(~[10, 20]); + let v2 = reversed::([10, 20]); assert_eq!(v2[0], 20); assert_eq!(v2[1], 10); v[0] = 30; assert_eq!(v2[0], 20); // Make sure they work with 0-length vectors too. - let v4 = reversed::(~[]); + let v4 = reversed::([]); assert_eq!(v4, ~[]); let mut v3: ~[int] = ~[]; reverse::(v3); @@ -3813,7 +3813,7 @@ mod tests { #[test] fn reversed_mut() { - let v2 = reversed::(~[10, 20]); + let v2 = reversed::([10, 20]); assert_eq!(v2[0], 20); assert_eq!(v2[1], 10); } @@ -3822,22 +3822,22 @@ mod tests { fn test_split() { fn f(x: &int) -> bool { *x == 3 } - assert_eq!(split(~[], f), ~[]); - assert_eq!(split(~[1, 2], f), ~[~[1, 2]]); - assert_eq!(split(~[3, 1, 2], f), ~[~[], ~[1, 2]]); - assert_eq!(split(~[1, 2, 3], f), ~[~[1, 2], ~[]]); - assert_eq!(split(~[1, 2, 3, 4, 3, 5], f), ~[~[1, 2], ~[4], ~[5]]); + assert_eq!(split([], f), ~[]); + assert_eq!(split([1, 2], f), ~[~[1, 2]]); + assert_eq!(split([3, 1, 2], f), ~[~[], ~[1, 2]]); + assert_eq!(split([1, 2, 3], f), ~[~[1, 2], ~[]]); + assert_eq!(split([1, 2, 3, 4, 3, 5], f), ~[~[1, 2], ~[4], ~[5]]); } #[test] fn test_splitn() { fn f(x: &int) -> bool { *x == 3 } - assert_eq!(splitn(~[], 1u, f), ~[]); - assert_eq!(splitn(~[1, 2], 1u, f), ~[~[1, 2]]); - assert_eq!(splitn(~[3, 1, 2], 1u, f), ~[~[], ~[1, 2]]); - assert_eq!(splitn(~[1, 2, 3], 1u, f), ~[~[1, 2], ~[]]); - assert!(splitn(~[1, 2, 3, 4, 3, 5], 1u, f) == + assert_eq!(splitn([], 1u, f), ~[]); + assert_eq!(splitn([1, 2], 1u, f), ~[~[1, 2]]); + assert_eq!(splitn([3, 1, 2], 1u, f), ~[~[], ~[1, 2]]); + assert_eq!(splitn([1, 2, 3], 1u, f), ~[~[1, 2], ~[]]); + assert!(splitn([1, 2, 3, 4, 3, 5], 1u, f) == ~[~[1, 2], ~[4, 3, 5]]); } @@ -3845,10 +3845,10 @@ mod tests { fn test_rsplit() { fn f(x: &int) -> bool { *x == 3 } - assert_eq!(rsplit(~[], f), ~[]); - assert_eq!(rsplit(~[1, 2], f), ~[~[1, 2]]); - assert_eq!(rsplit(~[1, 2, 3], f), ~[~[1, 2], ~[]]); - assert!(rsplit(~[1, 2, 3, 4, 3, 5], f) == + assert_eq!(rsplit([], f), ~[]); + assert_eq!(rsplit([1, 2], f), ~[~[1, 2]]); + assert_eq!(rsplit([1, 2, 3], f), ~[~[1, 2], ~[]]); + assert!(rsplit([1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]); } @@ -3856,53 +3856,46 @@ mod tests { fn test_rsplitn() { fn f(x: &int) -> bool { *x == 3 } - assert_eq!(rsplitn(~[], 1u, f), ~[]); - assert_eq!(rsplitn(~[1, 2], 1u, f), ~[~[1, 2]]); - assert_eq!(rsplitn(~[1, 2, 3], 1u, f), ~[~[1, 2], ~[]]); - assert!(rsplitn(~[1, 2, 3, 4, 3, 5], 1u, f) == - ~[~[1, 2, 3, 4], ~[5]]); + assert_eq!(rsplitn([], 1u, f), ~[]); + assert_eq!(rsplitn([1, 2], 1u, f), ~[~[1, 2]]); + assert_eq!(rsplitn([1, 2, 3], 1u, f), ~[~[1, 2], ~[]]); + assert_eq!(rsplitn([1, 2, 3, 4, 3, 5], 1u, f), ~[~[1, 2, 3, 4], ~[5]]); } #[test] fn test_partition() { // FIXME (#4355 maybe): using v.partition here crashes assert_eq!(partition(~[], |x: &int| *x < 3), (~[], ~[])); - assert!(partition(~[1, 2, 3], |x: &int| *x < 4) == - (~[1, 2, 3], ~[])); - assert!(partition(~[1, 2, 3], |x: &int| *x < 2) == - (~[1], ~[2, 3])); - assert!(partition(~[1, 2, 3], |x: &int| *x < 0) == - (~[], ~[1, 2, 3])); + assert_eq!(partition(~[1, 2, 3], |x: &int| *x < 4), (~[1, 2, 3], ~[])); + assert_eq!(partition(~[1, 2, 3], |x: &int| *x < 2), (~[1], ~[2, 3])); + assert_eq!(partition(~[1, 2, 3], |x: &int| *x < 0), (~[], ~[1, 2, 3])); } #[test] fn test_partitioned() { - assert_eq!((~[]).partitioned(|x: &int| *x < 3), (~[], ~[])) - assert!((~[1, 2, 3]).partitioned(|x: &int| *x < 4) == - (~[1, 2, 3], ~[])); - assert!((~[1, 2, 3]).partitioned(|x: &int| *x < 2) == - (~[1], ~[2, 3])); - assert!((~[1, 2, 3]).partitioned(|x: &int| *x < 0) == - (~[], ~[1, 2, 3])); + assert_eq!(([]).partitioned(|x: &int| *x < 3), (~[], ~[])) + assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (~[1, 2, 3], ~[])); + assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (~[1], ~[2, 3])); + assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (~[], ~[1, 2, 3])); } #[test] fn test_concat() { - assert_eq!(concat(~[~[1], ~[2,3]]), ~[1, 2, 3]); + assert_eq!(concat([~[1], ~[2,3]]), ~[1, 2, 3]); } #[test] fn test_connect() { - assert_eq!(connect(~[], &0), ~[]); - assert_eq!(connect(~[~[1], ~[2, 3]], &0), ~[1, 0, 2, 3]); - assert_eq!(connect(~[~[1], ~[2], ~[3]], &0), ~[1, 0, 2, 0, 3]); + assert_eq!(connect([], &0), ~[]); + assert_eq!(connect([~[1], ~[2, 3]], &0), ~[1, 0, 2, 3]); + assert_eq!(connect([~[1], ~[2], ~[3]], &0), ~[1, 0, 2, 0, 3]); } #[test] fn test_windowed () { fn t(n: uint, expected: &[&[int]]) { let mut i = 0; - for windowed(n, ~[1,2,3,4,5,6]) |v| { + for windowed(n, [1,2,3,4,5,6]) |v| { assert_eq!(v, expected[i]); i += 1; } @@ -3920,7 +3913,7 @@ mod tests { #[should_fail] #[ignore(cfg(windows))] fn test_windowed_() { - for windowed (0u, ~[1u,2u,3u,4u,5u,6u]) |_v| {} + for windowed (0u, [1u,2u,3u,4u,5u,6u]) |_v| {} } #[test]