Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Remove all uses of ~str from the test suite. #14166

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/auxiliary/cci_class_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod kitties {
meows : uint,

pub how_hungry : int,
pub name : ~str,
pub name : StrBuf,
}

impl cat {
Expand Down Expand Up @@ -41,7 +41,7 @@ pub mod kitties {
}
}

pub fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
pub fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/cci_class_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod kitty {
pub struct cat {
meows : uint,
pub how_hungry : int,
pub name : ~str,
pub name : StrBuf,
}

impl fmt::Show for cat {
Expand Down Expand Up @@ -50,7 +50,7 @@ pub mod kitty {
}
}

pub fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
pub fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ pub mod name_pool {
pub type name_pool = ();

pub trait add {
fn add(&self, s: ~str);
fn add(&self, s: StrBuf);
}

impl add for name_pool {
fn add(&self, _s: ~str) {
fn add(&self, _s: StrBuf) {
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/crateresolve5-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

#![crate_type = "lib"]

pub struct NameVal { pub name: ~str, pub val: int }
pub struct NameVal { pub name: StrBuf, pub val: int }

pub fn struct_nameval() -> NameVal {
NameVal { name: "crateresolve5".to_owned(), val: 10 }
NameVal { name: "crateresolve5".to_strbuf(), val: 10 }
}

pub enum e {
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/crateresolve5-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#![crate_type = "lib"]

pub struct NameVal { pub name: ~str, pub val: int }
pub struct NameVal { pub name: StrBuf, pub val: int }
pub fn struct_nameval() -> NameVal {
NameVal { name: "crateresolve5".to_owned(), val: 10 }
NameVal { name: "crateresolve5".to_strbuf(), val: 10 }
}

pub enum e {
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/explicit_self_xcrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait Foo {
}

pub struct Bar {
pub x: ~str
pub x: StrBuf
}

impl Foo for Bar {
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue-2414-a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ trait foo {
fn foo(&self);
}

impl foo for ~str {
impl foo for StrBuf {
fn foo(&self) {}
}
6 changes: 4 additions & 2 deletions src/test/auxiliary/issue-2631-a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ extern crate collections;
use std::cell::RefCell;
use collections::HashMap;

pub type header_map = HashMap<~str, @RefCell<Vec<@~str>>>;
pub type header_map = HashMap<StrBuf, @RefCell<Vec<@StrBuf>>>;

// the unused ty param is necessary so this gets monomorphized
pub fn request<T>(req: &header_map) {
let _x = (**((**req.get(&"METHOD".to_owned())).clone()).borrow().clone().get(0)).clone();
let _x = (**((**req.get(&"METHOD".to_strbuf())).clone()).borrow()
.clone()
.get(0)).clone();
}
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue13507.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod testtypes {
// Tests ty_float (does not test all variants of FloatTy)
pub type FooFloat = f64;

// For ty_str, what kind of string should I use? &'static str? ~str? Raw str?
// For ty_str, what kind of string should I use? &'static str? StrBuf? Raw str?

// Tests ty_enum
pub enum FooEnum {
Expand Down
6 changes: 3 additions & 3 deletions src/test/auxiliary/issue_2242_a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#![crate_type = "lib"]

trait to_strz {
fn to_strz() -> ~str;
fn to_strz() -> StrBuf;
}

impl to_strz for ~str {
fn to_strz() -> ~str { self.clone() }
impl to_strz for StrBuf {
fn to_strz() -> StrBuf { self.clone() }
}
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue_2242_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ extern crate a;
use a::to_strz;

impl to_strz for bool {
fn to_strz() -> ~str { fmt!("%b", self) }
fn to_strz() -> StrBuf { fmt!("%b", self) }
}
6 changes: 3 additions & 3 deletions src/test/auxiliary/reexported_static_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod sub_foo {
}

pub struct Boz {
unused_str: ~str
unused_str: StrBuf
}

impl Boz {
Expand All @@ -46,8 +46,8 @@ pub mod sub_foo {
}

impl Bort {
pub fn bort() -> ~str {
"bort()".to_owned()
pub fn bort() -> StrBuf {
"bort()".to_strbuf()
}
}
}
10 changes: 5 additions & 5 deletions src/test/auxiliary/static-methods-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
use std::int;

pub trait read {
fn readMaybe(s: ~str) -> Option<Self>;
fn readMaybe(s: StrBuf) -> Option<Self>;
}

impl read for int {
fn readMaybe(s: ~str) -> Option<int> {
from_str::<int>(s)
fn readMaybe(s: StrBuf) -> Option<int> {
from_str::<int>(s.as_slice())
}
}

impl read for bool {
fn readMaybe(s: ~str) -> Option<bool> {
fn readMaybe(s: StrBuf) -> Option<bool> {
match s.as_slice() {
"true" => Some(true),
"false" => Some(false),
Expand All @@ -33,7 +33,7 @@ impl read for bool {
}
}

pub fn read<T:read>(s: ~str) -> T {
pub fn read<T:read>(s: StrBuf) -> T {
match read::readMaybe(s) {
Some(x) => x,
_ => fail!("read failed!")
Expand Down
16 changes: 8 additions & 8 deletions src/test/bench/core-set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Results {
}
}

pub fn bench_str<T:MutableSet<~str>,
pub fn bench_str<T:MutableSet<StrBuf>,
R:rand::Rng>(
&mut self,
rng: &mut R,
Expand All @@ -90,11 +90,11 @@ impl Results {
let mut set = f();
timed(&mut self.sequential_strings, || {
for i in range(0u, num_keys) {
set.insert(i.to_str());
set.insert(i.to_str().to_strbuf());
}

for i in range(0u, num_keys) {
assert!(set.contains(&i.to_str()));
assert!(set.contains(&i.to_str().to_strbuf()));
}
})
}
Expand All @@ -103,7 +103,7 @@ impl Results {
let mut set = f();
timed(&mut self.random_strings, || {
for _ in range(0, num_keys) {
let s = rng.gen::<uint>().to_str();
let s = rng.gen::<uint>().to_str().to_strbuf();
set.insert(s);
}
})
Expand All @@ -112,11 +112,11 @@ impl Results {
{
let mut set = f();
for i in range(0u, num_keys) {
set.insert(i.to_str());
set.insert(i.to_str().to_strbuf());
}
timed(&mut self.delete_strings, || {
for i in range(0u, num_keys) {
assert!(set.remove(&i.to_str()));
assert!(set.remove(&i.to_str().to_strbuf()));
}
})
}
Expand Down Expand Up @@ -175,7 +175,7 @@ fn main() {
s
});
results.bench_str(&mut rng, num_keys, || {
let s: HashSet<~str> = HashSet::new();
let s: HashSet<StrBuf> = HashSet::new();
s
});
write_results("collections::HashSet", &results);
Expand All @@ -189,7 +189,7 @@ fn main() {
s
});
results.bench_str(&mut rng, num_keys, || {
let s: TreeSet<~str> = TreeSet::new();
let s: TreeSet<StrBuf> = TreeSet::new();
s
});
write_results("collections::TreeSet", &results);
Expand Down
10 changes: 6 additions & 4 deletions src/test/bench/core-std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ use std::vec;
use std::io::File;

macro_rules! bench (
($argv:expr, $id:ident) => (maybe_run_test($argv.as_slice(), stringify!($id).to_owned(), $id))
($argv:expr, $id:ident) => (maybe_run_test($argv.as_slice(),
stringify!($id).to_strbuf(),
$id))
)

fn main() {
let argv = os::args();
let argv = os::args().move_iter().map(|x| x.to_strbuf()).collect::<Vec<StrBuf>>();
let _tests = argv.slice(1, argv.len());

bench!(argv, shift_push);
Expand All @@ -40,13 +42,13 @@ fn main() {
bench!(argv, is_utf8_multibyte);
}

fn maybe_run_test(argv: &[~str], name: ~str, test: ||) {
fn maybe_run_test(argv: &[StrBuf], name: StrBuf, test: ||) {
let mut run_test = false;

if os::getenv("RUST_BENCH").is_some() {
run_test = true
} else if argv.len() > 0 {
run_test = argv.iter().any(|x| x == &"all".to_owned()) || argv.iter().any(|x| x == &name)
run_test = argv.iter().any(|x| x == &"all".to_strbuf()) || argv.iter().any(|x| x == &name)
}

if !run_test {
Expand Down
14 changes: 7 additions & 7 deletions src/test/bench/msgsend-pipes-shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
//println!("server exiting");
}

fn run(args: &[~str]) {
fn run(args: &[StrBuf]) {
let (to_parent, from_child) = channel();
let (to_child, from_parent) = channel();

let size = from_str::<uint>(args[1]).unwrap();
let workers = from_str::<uint>(args[2]).unwrap();
let size = from_str::<uint>(args[1].as_slice()).unwrap();
let workers = from_str::<uint>(args[2].as_slice()).unwrap();
let num_bytes = 100;
let start = time::precise_time_s();
let mut worker_results = Vec::new();
Expand Down Expand Up @@ -97,13 +97,13 @@ fn run(args: &[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
vec!("".to_owned(), "1000000".to_owned(), "10000".to_owned())
vec!("".to_strbuf(), "1000000".to_strbuf(), "10000".to_strbuf())
} else if args.len() <= 1u {
vec!("".to_owned(), "10000".to_owned(), "4".to_owned())
vec!("".to_strbuf(), "10000".to_strbuf(), "4".to_strbuf())
} else {
args.clone().move_iter().collect()
args.move_iter().map(|x| x.to_strbuf()).collect()
};

println!("{:?}", args);
println!("{}", args);
run(args.as_slice());
}
12 changes: 6 additions & 6 deletions src/test/bench/msgsend-pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
//println!("server exiting");
}

fn run(args: &[~str]) {
fn run(args: &[StrBuf]) {
let (to_parent, from_child) = channel();

let size = from_str::<uint>(args[1]).unwrap();
let workers = from_str::<uint>(args[2]).unwrap();
let size = from_str::<uint>(args[1].as_slice()).unwrap();
let workers = from_str::<uint>(args[2].as_slice()).unwrap();
let num_bytes = 100;
let start = time::precise_time_s();
let mut worker_results = Vec::new();
Expand Down Expand Up @@ -107,11 +107,11 @@ fn run(args: &[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
vec!("".to_owned(), "1000000".to_owned(), "8".to_owned())
vec!("".to_strbuf(), "1000000".to_strbuf(), "8".to_strbuf())
} else if args.len() <= 1u {
vec!("".to_owned(), "10000".to_owned(), "4".to_owned())
vec!("".to_strbuf(), "10000".to_strbuf(), "4".to_strbuf())
} else {
args.clone().move_iter().collect()
args.clone().move_iter().map(|x| x.to_strbuf()).collect()
};

println!("{:?}", args);
Expand Down
6 changes: 3 additions & 3 deletions src/test/bench/shootout-binarytrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ fn main() {
let b = bottom_up_tree(&arena, -i, depth);
chk += item_check(a) + item_check(b);
}
format!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk)
format_strbuf!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk)
})
}).collect::<Vec<Future<~str>>>();
}).collect::<Vec<Future<StrBuf>>>();

for message in messages.mut_iter() {
println!("{}", *message.get_ref());
Expand Down
8 changes: 5 additions & 3 deletions src/test/bench/shootout-chameneos-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn creature(
mut color: Color,
from_rendezvous: Receiver<CreatureInfo>,
to_rendezvous: Sender<CreatureInfo>,
to_rendezvous_log: Sender<~str>
to_rendezvous_log: Sender<StrBuf>
) {
let mut creatures_met = 0;
let mut evil_clones_met = 0;
Expand All @@ -132,7 +132,9 @@ fn creature(
}
}
// log creatures met and evil clones of self
let report = format!("{}{}", creatures_met, Number(evil_clones_met));
let report = format_strbuf!("{}{}",
creatures_met,
Number(evil_clones_met));
to_rendezvous_log.send(report);
}

Expand All @@ -141,7 +143,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
let (to_rendezvous, from_creatures) = channel::<CreatureInfo>();

// these channels will be passed to the creatures so they can talk to us
let (to_rendezvous_log, from_creatures_log) = channel::<~str>();
let (to_rendezvous_log, from_creatures_log) = channel::<StrBuf>();

// these channels will allow us to talk to each creature by 'name'/index
let mut to_creature: Vec<Sender<CreatureInfo>> =
Expand Down
Loading