fix tests, remove some warnings

This commit is contained in:
Huon Wilson 2013-06-11 02:34:14 +10:00
parent 2fa83c0503
commit e8782eeb63
22 changed files with 18 additions and 44 deletions

View file

@ -802,15 +802,15 @@ Use declarations support a number of convenient shortcuts:
An example of `use` declarations: An example of `use` declarations:
~~~~ ~~~~
use std::float::{sin, pow}; use std::float::sin;
use std::option::Some; use std::option::{Some, None};
fn main() { fn main() {
// Equivalent to 'info!(std::float::pow(std::float::sin(1.0), 2.0));' // Equivalent to 'info!(std::float::sin(1.0));'
info!(pow(sin(1.0), 2.0)); info!(sin(1.0));
// Equivalent to 'info!(std::option::Some(1.0));' // Equivalent to 'info!(~[std::option::Some(1.0), std::option::None]);'
info!(Some(1.0)); info!(~[Some(1.0), None]);
} }
~~~~ ~~~~

View file

@ -11,7 +11,6 @@
use core::prelude::*; use core::prelude::*;
use core::io; use core::io;
use core::str;
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str } pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }

View file

@ -16,7 +16,6 @@ use common;
use core::iterator::IteratorUtil; use core::iterator::IteratorUtil;
use core::io; use core::io;
use core::os; use core::os;
use core::str;
pub struct TestProps { pub struct TestProps {
// Lines that should be expected, in order, on standard out // Lines that should be expected, in order, on standard out

View file

@ -19,7 +19,6 @@ use core::cmp::Eq;
use core::io::{Reader, ReaderUtil}; use core::io::{Reader, ReaderUtil};
use core::io; use core::io;
use core::hashmap::HashMap; use core::hashmap::HashMap;
use core::str;
use core::to_bytes; use core::to_bytes;
use core::uint; use core::uint;
@ -394,7 +393,7 @@ enum Input {
// returns userinfo, host, port, and unparsed part, or an error // returns userinfo, host, port, and unparsed part, or an error
fn get_authority(rawurl: &str) -> fn get_authority(rawurl: &str) ->
Result<(Option<UserInfo>, ~str, Option<~str>, ~str), ~str> { Result<(Option<UserInfo>, ~str, Option<~str>, ~str), ~str> {
if !raw_url.starts_with("//") { if !rawurl.starts_with("//") {
// there is no authority. // there is no authority.
return Ok((None, ~"", None, rawurl.to_str())); return Ok((None, ~"", None, rawurl.to_str()));
} }

View file

@ -40,6 +40,7 @@ use core::prelude::*;
use core::iterator::IteratorUtil; use core::iterator::IteratorUtil;
use core::uint; use core::uint;
use core::vec; use core::vec;
use core::str;
/// The type of ropes. /// The type of ropes.
pub type Rope = node::Root; pub type Rope = node::Root;
@ -1187,8 +1188,6 @@ pub mod node {
pub mod char_iterator { pub mod char_iterator {
use core::prelude::*; use core::prelude::*;
use core::str;
use rope::node::{Leaf, Node}; use rope::node::{Leaf, Node};
use rope::node::leaf_iterator; use rope::node::leaf_iterator;

View file

@ -20,7 +20,6 @@ use core::cmp;
use core::io::{ReaderUtil}; use core::io::{ReaderUtil};
use core::io; use core::io;
use core::option::{Option, Some, None}; use core::option::{Option, Some, None};
use core::str;
use core::to_str::ToStr; use core::to_str::ToStr;
use core::uint; use core::uint;

View file

@ -37,7 +37,6 @@ use std::result;
use std::run; use std::run;
use std::str; use std::str;
use std::uint; use std::uint;
use std::vec;
use syntax::diagnostic; use syntax::diagnostic;
use syntax::parse::token::ident_interner; use syntax::parse::token::ident_interner;

View file

@ -1995,7 +1995,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
debug!("trans_enum_variant: name=%s tps=%s repr=%? enum_ty=%s", debug!("trans_enum_variant: name=%s tps=%s repr=%? enum_ty=%s",
unsafe { str::raw::from_c_str(llvm::LLVMGetValueName(llfndecl)) }, unsafe { str::raw::from_c_str(llvm::LLVMGetValueName(llfndecl)) },
~"[" + ty_param_substs.map(|&t| ty_to_str(ccx.tcx.connect(t)), ", ") + "]", ~"[" + ty_param_substs.map(|&t| ty_to_str(ccx.tcx, t)).connect(", ") + "]",
repr, ty_to_str(ccx.tcx, enum_ty)); repr, ty_to_str(ccx.tcx, enum_ty));
adt::trans_start_init(bcx, repr, fcx.llretptr.get(), disr); adt::trans_start_init(bcx, repr, fcx.llretptr.get(), disr);

View file

@ -192,9 +192,7 @@ pub fn Invoke(cx: block,
terminate(cx, "Invoke"); terminate(cx, "Invoke");
debug!("Invoke(%s with arguments (%s))", debug!("Invoke(%s with arguments (%s))",
val_str(cx.ccx().tn, Fn), val_str(cx.ccx().tn, Fn),
vec::map(Args.connect(|a| val_str(cx.ccx().tn, Args.map(|a| val_str(cx.ccx().tn, *a).to_owned()).connect(", "));
*a).to_owned()),
", "));
unsafe { unsafe {
count_insn(cx, "invoke"); count_insn(cx, "invoke");
llvm::LLVMBuildInvoke(B(cx), llvm::LLVMBuildInvoke(B(cx),

View file

@ -115,7 +115,6 @@ use core::iterator::IteratorUtil;
use core::cast::transmute; use core::cast::transmute;
use core::hashmap::HashMap; use core::hashmap::HashMap;
use core::result; use core::result;
use core::str;
use core::util::replace; use core::util::replace;
use core::vec; use core::vec;
use extra::list::Nil; use extra::list::Nil;

View file

@ -18,7 +18,6 @@ use middle::typeck::infer::InferCtxt;
use middle::typeck::infer::unify::{Redirect, Root, VarValue}; use middle::typeck::infer::unify::{Redirect, Root, VarValue};
use util::ppaux::{mt_to_str, ty_to_str, trait_ref_to_str}; use util::ppaux::{mt_to_str, ty_to_str, trait_ref_to_str};
use core::str;
use core::uint; use core::uint;
use syntax::ast; use syntax::ast;

View file

@ -16,7 +16,6 @@ use syntax::visit;
use core::hashmap::HashSet; use core::hashmap::HashSet;
use core::io; use core::io;
use core::str;
use extra; use extra;
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {

View file

@ -143,7 +143,7 @@ fn try_parsing_version(s: &str) -> Option<Version> {
let s = s.trim(); let s = s.trim();
debug!("Attempting to parse: %s", s); debug!("Attempting to parse: %s", s);
let mut parse_state = Start; let mut parse_state = Start;
for s.iter().advance |&c| { for s.iter().advance |c| {
if char::is_digit(c) { if char::is_digit(c) {
parse_state = SawDigit; parse_state = SawDigit;
} }
@ -171,7 +171,7 @@ fn is_url_like(p: &RemotePath) -> bool {
/// Otherwise, return None. /// Otherwise, return None.
pub fn split_version<'a>(s: &'a str) -> Option<(&'a str, Version)> { pub fn split_version<'a>(s: &'a str) -> Option<(&'a str, Version)> {
// reject strings with multiple '#'s // reject strings with multiple '#'s
if s.splitn_iter('#', 2).count() > 1 { if s.splitn_iter('#', 2).count() > 2 {
return None; return None;
} }
match s.rfind('#') { match s.rfind('#') {

View file

@ -1836,7 +1836,6 @@ mod tests {
use io; use io;
use path::Path; use path::Path;
use result; use result;
use str;
use u64; use u64;
use vec; use vec;

View file

@ -1800,7 +1800,7 @@ impl<'self> StrSlice<'self> for &'self str {
*/ */
#[inline] #[inline]
fn substr(&self, begin: uint, n: uint) -> &'self str { fn substr(&self, begin: uint, n: uint) -> &'self str {
s.slice(begin, begin + count_bytes(s, begin, n)) self.slice(begin, begin + count_bytes(*self, begin, n))
} }
/// Escape each char in `s` with char::escape_default. /// Escape each char in `s` with char::escape_default.
#[inline] #[inline]
@ -2318,7 +2318,6 @@ impl<'self> Iterator<u8> for StrBytesRevIterator<'self> {
mod tests { mod tests {
use iterator::IteratorUtil; use iterator::IteratorUtil;
use container::Container; use container::Container;
use char;
use option::Some; use option::Some;
use libc::c_char; use libc::c_char;
use libc; use libc;
@ -3026,14 +3025,6 @@ mod tests {
assert_eq!(~"YMCA", map("ymca", |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_chars() {
let ss = ~"ศไทย中华Việt Nam";
assert!(~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a',
'm']
== to_chars(ss));
}
#[test] #[test]
fn test_utf16() { fn test_utf16() {
let pairs = let pairs =

View file

@ -202,7 +202,6 @@ impl ToStrConsume for ~[Ascii] {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use str;
macro_rules! v2ascii ( macro_rules! v2ascii (
( [$($e:expr),*]) => ( [$(Ascii{chr:$e}),*]); ( [$($e:expr),*]) => ( [$(Ascii{chr:$e}),*]);

View file

@ -24,7 +24,6 @@ use syntax::parse::token::special_idents;
use core::cmp; use core::cmp;
use core::hashmap::HashMap; use core::hashmap::HashMap;
use core::str;
use core::vec; use core::vec;
pub enum path_elt { pub enum path_elt {

View file

@ -23,7 +23,6 @@ use visit;
use core::hashmap::HashMap; use core::hashmap::HashMap;
use core::int; use core::int;
use core::option; use core::option;
use core::str;
use core::to_bytes; use core::to_bytes;
pub fn path_name_i(idents: &[ident]) -> ~str { pub fn path_name_i(idents: &[ident]) -> ~str {

View file

@ -21,7 +21,6 @@ use ext::base::*;
use parse; use parse;
use parse::token; use parse::token;
use core::str;
use core::vec; use core::vec;
enum State { enum State {

View file

@ -42,7 +42,6 @@ use core::prelude::*;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::pipes::proto::{protocol_}; use ext::pipes::proto::{protocol_};
use core::str;
use extra::bitv::Bitv; use extra::bitv::Bitv;
pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) { pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {

View file

@ -24,7 +24,6 @@ use parse::token;
use core::iterator::IteratorUtil; use core::iterator::IteratorUtil;
use core::hashmap::HashMap; use core::hashmap::HashMap;
use core::str;
use core::uint; use core::uint;
use core::vec; use core::vec;
@ -371,14 +370,14 @@ pub fn parse(
} else { } else {
if (bb_eis.len() > 0u && next_eis.len() > 0u) if (bb_eis.len() > 0u && next_eis.len() > 0u)
|| bb_eis.len() > 1u { || bb_eis.len() > 1u {
let nts = vec::map(bb_eis.connect(|ei| { let nts = bb_eis.map(|ei| {
match ei.elts[ei.idx].node { match ei.elts[ei.idx].node {
match_nonterminal(ref bind,ref name,_) => { match_nonterminal(ref bind,ref name,_) => {
fmt!("%s ('%s')", *ident_to_str(name), fmt!("%s ('%s')", *ident_to_str(name),
*ident_to_str(bind)) *ident_to_str(bind))
} }
_ => fail!() _ => fail!()
} }), " or "); } }).connect(" or ");
return error(sp, fmt!( return error(sp, fmt!(
"Local ambiguity: multiple parsing options: \ "Local ambiguity: multiple parsing options: \
built-in NTs %s or %u other options.", built-in NTs %s or %u other options.",

View file

@ -14,7 +14,8 @@
extern mod std; extern mod std;
use std::{str, int, vec}; use std::str::StrVector;
use std::{int, vec};
trait to_str { trait to_str {
fn to_str(&self) -> ~str; fn to_str(&self) -> ~str;
@ -26,7 +27,7 @@ impl to_str for int {
impl<T:to_str> to_str for ~[T] { impl<T:to_str> to_str for ~[T] {
fn to_str(&self) -> ~str { fn to_str(&self) -> ~str {
~"[" + self.map(|e| e.to_str()).connect(", ") + "]" ~"[" + vec::map(*self, |e| e.to_str()).connect(", ") + "]"
} }
} }