Silence various warnings throughout test modules

This commit is contained in:
Alex Crichton 2013-05-27 18:04:00 -05:00
parent 8749cb59d8
commit b04c40bb1c
37 changed files with 166 additions and 170 deletions

View file

@ -510,7 +510,6 @@ mod tests {
use core::prelude::*;
use core::cell::Cell;
use arc::*;
use arc;
#[test]
fn manually_share_arc() {

View file

@ -1197,7 +1197,7 @@ mod tests {
#[test]
fn test_from_bytes() {
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
let str = ~"10110110" + ~"00000000" + ~"11111111";
let str = ~"10110110" + "00000000" + "11111111";
assert_eq!(bitv.to_str(), str);
}

View file

@ -927,7 +927,7 @@ mod test {
fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) {
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
// The control word is followed by garbage
let bytes = CONTINUE.to_vec() + ~[0];
let bytes = CONTINUE.to_vec() + [0];
let port = loader(bytes);
let res: Option<int> = port.try_recv();
assert!(res.is_none());
@ -951,7 +951,7 @@ mod test {
1, sys::size_of::<u64>()) |len_bytes| {
len_bytes.to_vec()
};
let bytes = CONTINUE.to_vec() + len_bytes + ~[0, 0, 0, 0];
let bytes = CONTINUE.to_vec() + len_bytes + [0, 0, 0, 0];
let port = loader(bytes);

View file

@ -1880,13 +1880,13 @@ mod tests {
]));
assert_eq!(result::unwrap(from_str(
~"{" +
~"\"a\": 1.0, " +
~"\"b\": [" +
~"true," +
~"\"foo\\nbar\", " +
~"{ \"c\": {\"d\": null} } " +
~"]" +
~"}")),
"\"a\": 1.0, " +
"\"b\": [" +
"true," +
"\"foo\\nbar\", " +
"{ \"c\": {\"d\": null} } " +
"]" +
"}")),
mk_object([
(~"a", Number(1.0f)),
(~"b", List(~[

View file

@ -375,7 +375,6 @@ mod test {
use uv;
use core::result;
use core::vec;
#[test]
fn test_ip_ipv4_parse_and_format_ip() {

View file

@ -317,7 +317,7 @@ mod tests {
Test {
input:
~"abcdbcdecdefdefgefghfghighij" +
~"hijkijkljklmklmnlmnomnopnopq",
"hijkijkljklmklmnlmnomnopnopq",
output: ~[
0x84u8, 0x98u8, 0x3Eu8, 0x44u8,
0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8,

View file

@ -746,8 +746,6 @@ fn shift_vec<T:Copy>(dest: &mut [T],
#[cfg(test)]
mod test_qsort3 {
use core::prelude::*;
use sort::*;
use core::vec;

View file

@ -720,7 +720,6 @@ mod tests {
use core::cast;
use core::cell::Cell;
use core::ptr;
use core::result;
use core::task;
use core::vec;

View file

@ -30,7 +30,6 @@ mod tests {
use core::prelude::*;
use tempfile::mkdtemp;
use tempfile;
use core::os;
#[test]

View file

@ -1205,8 +1205,8 @@ mod tests {
// abbreviation.
let rfc822 = local.rfc822();
let prefix = ~"Fri, 13 Feb 2009 15:31:30 ";
assert!(rfc822 == prefix + ~"PST" ||
rfc822 == prefix + ~"Pacific Standard Time");
assert!(rfc822 == prefix + "PST" ||
rfc822 == prefix + "Pacific Standard Time");
assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009");
assert_eq!(local.rfc822z(), ~"Fri, 13 Feb 2009 15:31:30 -0800");

View file

@ -126,9 +126,7 @@ mod test {
use uv::ll;
use uv_iotask::IoTask;
use core::old_iter;
use core::libc;
use core::ptr;
use core::task;
use core::cast::transmute;
use core::libc::c_void;
@ -228,7 +226,7 @@ mod test {
for cycles.times {
exit_po.recv();
};
debug!(~"test_stress_gl_uv_global_loop_high_level_global_timer"+
~" exiting successfully!");
debug!("test_stress_gl_uv_global_loop_high_level_global_timer \
exiting successfully!");
}
}

View file

@ -139,7 +139,7 @@ pub fn stash_expr_if(c: @fn(@ast::expr, test_mode)->bool,
e: @ast::expr,
tm: test_mode) {
if c(e, tm) {
*es = *es + ~[e];
*es = *es + [e];
} else {
/* now my indices are wrong :( */
}
@ -425,7 +425,7 @@ pub fn check_running(exe_filename: &Path) -> happiness {
let p = run::process_output(
"/Users/jruderman/scripts/timed_run_rust_program.py",
[exe_filename.to_str()]);
let comb = str::from_bytes(p.output) + ~"\n" + str::from_bytes(p.error);
let comb = str::from_bytes(p.output) + "\n" + str::from_bytes(p.error);
if str::len(comb) > 1u {
error!("comb comb comb: %?", comb);
}

View file

@ -171,6 +171,7 @@ pub fn get_absolute_rpath(lib: &Path) -> Path {
os::make_absolute(lib).dir_path()
}
#[cfg(stage0)]
pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
let install_prefix = env!("CFG_PREFIX");
@ -182,6 +183,18 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
os::make_absolute(&Path(install_prefix).push_rel(&tlib))
}
#[cfg(not(stage0))]
pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
let install_prefix = env!("CFG_PREFIX");
if install_prefix == "" {
fail!("rustc compiled without CFG_PREFIX environment variable");
}
let tlib = filesearch::relative_target_lib_path(target_triple);
os::make_absolute(&Path(install_prefix).push_rel(&tlib))
}
pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] {
let mut set = HashSet::new();
let mut minimized = ~[];
@ -193,20 +206,13 @@ pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] {
minimized
}
#[cfg(unix)]
#[cfg(unix, test)]
mod test {
use core::prelude::*;
// FIXME(#2119): the outer attribute should be #[cfg(unix, test)], then
// these redundant #[cfg(test)] blocks can be removed
#[cfg(test)]
#[cfg(test)]
use back::rpath::{get_absolute_rpath, get_install_prefix_rpath};
#[cfg(test)]
use back::rpath::{get_relative_to, get_rpath_relative_to_output};
#[cfg(test)]
use back::rpath::{minimize_rpaths, rpaths_to_flags};
#[cfg(test)]
use driver::session;
#[test]

View file

@ -641,7 +641,7 @@ pub fn build_session_options(binary: @~str,
~"3" => Aggressive,
_ => {
early_error(demitter, ~"optimization level needs " +
~"to be between 0-3")
"to be between 0-3")
}
}
} else { No }
@ -934,7 +934,7 @@ mod test {
#[test]
fn test_switch_implies_cfg_test() {
let matches =
&match getopts(~[~"--test"], optgroups()) {
&match getopts([~"--test"], optgroups()) {
Ok(copy m) => m,
Err(copy f) => fail!("test_switch_implies_cfg_test: %s", getopts::fail_str(f))
};

View file

@ -384,8 +384,8 @@ mod test {
fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate {
let mut attrs = ~[];
if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; }
if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; }
if with_bin { attrs += [make_crate_type_attr(~"bin")]; }
if with_lib { attrs += [make_crate_type_attr(~"lib")]; }
@codemap::respan(codemap::dummy_sp(), ast::crate_ {
module: ast::_mod { view_items: ~[], items: ~[] },
attrs: attrs,

View file

@ -1980,7 +1980,7 @@ pub fn type_to_str_inner(names: @TypeNames, outer0: &[TypeRef], ty: TypeRef)
let mut s = ~"";
let mut first: bool = true;
for tys.each |t| {
if first { first = false; } else { s += ~", "; }
if first { first = false; } else { s += ", "; }
s += type_to_str_inner(names, outer, *t).to_owned();
}
// [Note at-str] FIXME #2543: Could rewrite this without the copy,

View file

@ -66,7 +66,7 @@ Although these two functions are never called, they are here
for a VERY GOOD REASON. See #3670
*/
pub fn add_u16(dest: &mut ~[u8], val: u16) {
*dest += ~[(val & 0xffu16) as u8, (val >> 8u16) as u8];
*dest += [(val & 0xffu16) as u8, (val >> 8u16) as u8];
}
pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) {

View file

@ -30,7 +30,6 @@ use util::enum_set::{EnumSet, CLike};
use core::ptr::to_unsafe_ptr;
use core::to_bytes;
use core::hashmap::{HashMap, HashSet};
use extra::smallintmap::SmallIntMap;
use syntax::ast::*;
use syntax::ast_util::is_local;
use syntax::ast_util;

View file

@ -157,7 +157,7 @@ pub fn version(argv0: &str) {
pub fn usage(argv0: &str) {
let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
io::println(groups::usage(message, optgroups()) +
~"Additional help:
"Additional help:
-W help Print 'lint' options and default settings
-Z help Print internal options for debugging rustc
");

View file

@ -78,7 +78,6 @@ mod test {
fn parse_attributes(source: ~str) -> ~[ast::attribute] {
use syntax::parse;
use syntax::parse::attr::parser_attr;
use syntax::codemap;
let parse_sess = syntax::parse::new_parse_sess(None);
let parser = parse::new_parser_from_source_str(

View file

@ -166,7 +166,7 @@ pub fn paragraphs(s: &str) -> ~[~str] {
accum = if str::is_empty(accum) {
copy *line
} else {
accum + ~"\n" + *line
accum + "\n" + *line
}
}
@ -174,7 +174,7 @@ pub fn paragraphs(s: &str) -> ~[~str] {
};
if !accum.is_empty() {
paras + ~[accum]
paras + [accum]
} else {
paras
}

View file

@ -171,7 +171,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
}
pub fn header_name(doc: doc::ItemTag) -> ~str {
let fullpath = str::connect(doc.path() + ~[doc.name()], "::");
let fullpath = str::connect(doc.path() + [doc.name()], "::");
match &doc {
&doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
fullpath
@ -190,9 +190,9 @@ pub fn header_name(doc: doc::ItemTag) -> ~str {
let mut trait_part = ~"";
for doc.trait_types.eachi |i, trait_type| {
if i == 0 {
trait_part += ~" of ";
trait_part += " of ";
} else {
trait_part += ~", ";
trait_part += ", ";
}
trait_part += *trait_type;
}
@ -668,7 +668,7 @@ mod test {
assert!(str::contains(markdown, "% Crate core"));
}
doc::ItemPage(_) => {
assert!(str::contains(markdown, ~"% Module a"));
assert!(str::contains(markdown, "% Module a"));
}
}
}

View file

@ -38,7 +38,7 @@ impl WriterUtils for Writer {
}
fn put_line(&self, str: ~str) {
self.put_str(str + ~"\n");
self.put_str(str + "\n");
}
fn put_done(&self) {
@ -159,7 +159,7 @@ pub fn make_filename(
}
}
doc::ItemPage(doc) => {
str::connect(doc.path() + ~[doc.name()], "_")
str::connect(doc.path() + [doc.name()], "_")
}
}
};

View file

@ -69,7 +69,7 @@ fn make_doc_from_pages(page_port: &PagePort) -> doc::Doc {
loop {
let val = page_port.recv();
if val.is_some() {
pages += ~[val.unwrap()];
pages += [val.unwrap()];
} else {
break;
}

View file

@ -48,7 +48,7 @@ fn test_run_passes() {
doc::CratePage(doc::CrateDoc{
topmod: doc::ModDoc{
item: doc::ItemDoc {
name: doc.cratemod().name() + ~"two",
name: doc.cratemod().name() + "two",
.. copy doc.cratemod().item
},
items: ~[],
@ -67,7 +67,7 @@ fn test_run_passes() {
doc::CratePage(doc::CrateDoc{
topmod: doc::ModDoc{
item: doc::ItemDoc {
name: doc.cratemod().name() + ~"three",
name: doc.cratemod().name() + "three",
.. copy doc.cratemod().item
},
items: ~[],

View file

@ -113,7 +113,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
match parse_header(copy *line) {
Some(header) => {
if current_section.is_some() {
sections += ~[(&current_section).get()];
sections += [(&current_section).get()];
}
current_section = Some(doc::Section {
header: header,
@ -124,14 +124,14 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
match copy current_section {
Some(section) => {
current_section = Some(doc::Section {
body: section.body + ~"\n" + *line,
body: section.body + "\n" + *line,
.. section
});
}
None => {
new_desc = match copy new_desc {
Some(desc) => {
Some(desc + ~"\n" + *line)
Some(desc + "\n" + *line)
}
None => {
Some(copy *line)
@ -144,7 +144,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
}
if current_section.is_some() {
sections += ~[current_section.get()];
sections += [current_section.get()];
}
(new_desc, sections)

View file

@ -272,11 +272,11 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
~"help" => {
io::println(
~":{\\n ..lines.. \\n:}\\n - execute multiline command\n" +
~":load <crate> ... - \
":load <crate> ... - \
loads given crates as dynamic libraries\n" +
~":clear - clear the bindings\n" +
~":exit - exit from the repl\n" +
~":help - show this message");
":clear - clear the bindings\n" +
":exit - exit from the repl\n" +
":help - show this message");
}
~"load" => {
let mut loaded_crates: ~[~str] = ~[];
@ -317,10 +317,10 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
match get_line(use_rl, "rusti| ") {
None => fail!("unterminated multiline command :{ .. :}"),
Some(line) => {
if str::trim(line) == ~":}" {
if str::trim(line) == ":}" {
end_multiline = true;
} else {
multiline_cmd += line + ~"\n";
multiline_cmd += line + "\n";
}
}
}

View file

@ -40,7 +40,7 @@ fn fake_pkg() -> PkgId {
}
fn remote_pkg() -> PkgId {
let remote = RemotePath(Path(~"github.com/catamorphism/test-pkg"));
let remote = RemotePath(Path("github.com/catamorphism/test-pkg"));
PkgId {
local_path: normalize(copy remote),
remote_path: remote,
@ -52,23 +52,23 @@ fn remote_pkg() -> PkgId {
fn writeFile(file_path: &Path, contents: ~str) {
let out: @io::Writer =
result::get(&io::file_writer(file_path,
~[io::Create, io::Truncate]));
[io::Create, io::Truncate]));
out.write_line(contents);
}
fn mk_temp_workspace(short_name: &LocalPath) -> Path {
let workspace = mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir");
// include version number in directory name
let package_dir = workspace.push(~"src").push(fmt!("%s-0.1", short_name.to_str()));
let package_dir = workspace.push("src").push(fmt!("%s-0.1", short_name.to_str()));
assert!(os::mkdir_recursive(&package_dir, u_rwx));
// Create main, lib, test, and bench files
writeFile(&package_dir.push(~"main.rs"),
writeFile(&package_dir.push("main.rs"),
~"fn main() { let _x = (); }");
writeFile(&package_dir.push(~"lib.rs"),
writeFile(&package_dir.push("lib.rs"),
~"pub fn f() { let _x = (); }");
writeFile(&package_dir.push(~"test.rs"),
writeFile(&package_dir.push("test.rs"),
~"#[test] pub fn f() { (); }");
writeFile(&package_dir.push(~"bench.rs"),
writeFile(&package_dir.push("bench.rs"),
~"#[bench] pub fn f() { (); }");
workspace
}
@ -98,7 +98,7 @@ fn test_sysroot() -> Path {
#[ignore(cfg(target_arch = "x86"))]
fn test_make_dir_rwx() {
let temp = &os::tmpdir();
let dir = temp.push(~"quux");
let dir = temp.push("quux");
assert!(!os::path_exists(&dir) ||
os::remove_dir_recursive(&dir));
debug!("Trying to make %s", dir.to_str());
@ -176,10 +176,10 @@ fn test_install_url() {
debug!("lib = %s", lib.to_str());
assert!(os::path_exists(&lib));
assert!(is_rwx(&lib));
let built_test = built_test_in_workspace(&temp_pkg_id, &workspace).expect(~"test_install_url");
let built_test = built_test_in_workspace(&temp_pkg_id, &workspace).expect("test_install_url");
assert!(os::path_exists(&built_test));
let built_bench = built_bench_in_workspace(&temp_pkg_id,
&workspace).expect(~"test_install_url");
&workspace).expect("test_install_url");
assert!(os::path_exists(&built_bench));
// And that the test and bench executables aren't installed
let test = target_test_in_workspace(&temp_pkg_id, &workspace);

View file

@ -536,15 +536,15 @@ mod test {
#[test]
fn test_is_cmd() {
assert!(is_cmd(~"build"));
assert!(is_cmd(~"clean"));
assert!(is_cmd(~"do"));
assert!(is_cmd(~"info"));
assert!(is_cmd(~"install"));
assert!(is_cmd(~"prefer"));
assert!(is_cmd(~"test"));
assert!(is_cmd(~"uninstall"));
assert!(is_cmd(~"unprefer"));
assert!(is_cmd("build"));
assert!(is_cmd("clean"));
assert!(is_cmd("do"));
assert!(is_cmd("info"));
assert!(is_cmd("install"));
assert!(is_cmd("prefer"));
assert!(is_cmd("test"));
assert!(is_cmd("uninstall"));
assert!(is_cmd("unprefer"));
}
}

View file

@ -300,7 +300,7 @@ mod test {
#[test]
fn append_test() {
assert_eq!(@[1,2,3] + @[4,5,6], @[1,2,3,4,5,6]);
assert_eq!(@[1,2,3] + [4,5,6], @[1,2,3,4,5,6]);
}
#[test]

View file

@ -487,7 +487,7 @@ mod tests {
assert!(f == i && f == v);
buf += ~[t as u8];
buf += [t as u8];
stream_inc.input([t as u8]);
t += 1;

View file

@ -12,10 +12,7 @@
use option::*;
use either::*;
use rt;
use rt::logging::{Logger, StdErrLogger};
use cast;
use str;
/// Turns on logging to stdout globally
pub fn console_on() {
@ -40,10 +37,13 @@ pub fn console_off() {
#[cfg(not(test))]
#[lang="log_type"]
pub fn log_type<T>(level: u32, object: &T) {
use cast;
use container::Container;
use io;
use libc;
use repr;
use rt;
use str;
use vec;
let bytes = do io::with_bytes_writer |writer| {

View file

@ -757,45 +757,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]
@ -838,36 +838,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]

View file

@ -496,29 +496,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]
@ -551,36 +551,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]

View file

@ -1481,7 +1481,7 @@ mod tests {
fn test_getenv_big() {
let mut s = ~"";
let mut i = 0;
while i < 100 { s += ~"aaaaaaaaaa"; i += 1; }
while i < 100 { s += "aaaaaaaaaa"; i += 1; }
let n = make_rand_name();
setenv(n, s);
debug!(copy s);
@ -1658,7 +1658,7 @@ mod tests {
};
assert!((ostream as uint != 0u));
let s = ~"hello";
let mut buf = str::to_bytes(s) + ~[0 as u8];
let mut buf = str::to_bytes(s) + [0 as u8];
do vec::as_mut_buf(buf) |b, _len| {
assert!((libc::fwrite(b as *c_void, 1u as size_t,
(str::len(s) + 1u) as size_t, ostream)

View file

@ -11,8 +11,8 @@
//! Unsafe pointer utility functions
use cast;
use libc;
use libc::{c_void, size_t};
#[cfg(stage0)] use libc;
#[cfg(stage0)] use libc::{c_void, size_t};
use option::{Option, Some, None};
use sys;

View file

@ -3147,7 +3147,7 @@ mod tests {
}
t([~"you", ~"know", ~"I'm", ~"no", ~"good"],
" ", "you know I'm no good");
let v: &[~str] = ~[];
let v: &[~str] = [];
t(v, " ", "");
t([~"hi"], " ", "hi");
}