Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jan 7, 2015
1 parent 24ccb34 commit 4b4ef71
Show file tree
Hide file tree
Showing 56 changed files with 154 additions and 150 deletions.
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

#![crate_type = "bin"]
#![feature(phase, slicing_syntax, globs, unboxed_closures)]
#![feature(slicing_syntax, globs, unboxed_closures)]

#![deny(warnings)]

Expand Down
4 changes: 2 additions & 2 deletions src/doc/guide-error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ fn parse_version(header: &[u8]) -> Result<Version, ParseError> {
let version = parse_version(&[1, 2, 3, 4]);
match version {
Ok(v) => {
println!("working with version: {}", v);
println!("working with version: {:?}", v);
}
Err(e) => {
println!("error parsing header: {}", e);
println!("error parsing header: {:?}", e);
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions src/doc/guide-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ the pattern in the above code:
# let input_1 = T::SpecialA(0);
# let input_2 = T::SpecialA(0);
macro_rules! early_return {
($inp:expr $sp:path) => ( // invoke it like `(input_5 SpecialE)`
($inp:expr, $sp:path) => ( // invoke it like `(input_5 SpecialE)`
match $inp {
$sp(x) => { return x; }
_ => {}
}
);
}
// ...
early_return!(input_1 T::SpecialA);
early_return!(input_1, T::SpecialA);
// ...
early_return!(input_2 T::SpecialB);
early_return!(input_2, T::SpecialB);
# return 0;
# }
# fn main() {}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ enum List<T> {
fn main() {
let list: List<int> = List::Cons(1, box List::Cons(2, box List::Cons(3, box List::Nil)));
println!("{}", list);
println!("{:?}", list);
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//! let five = five.clone();
//!
//! Thread::spawn(move || {
//! println!("{}", five);
//! println!("{:?}", five);
//! });
//! }
//! ```
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

#![no_std]
#![allow(unknown_features)]
#![feature(lang_items, phase, unsafe_destructor)]
#![feature(lang_items, unsafe_destructor)]

#[macro_use]
extern crate core;
Expand Down
18 changes: 9 additions & 9 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ static FALSE: bool = false;
/// bv.set(3, true);
/// bv.set(5, true);
/// bv.set(7, true);
/// println!("{}", bv.to_string());
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
///
/// // flip all values in bitvector, producing non-primes less than 10
/// bv.negate();
/// println!("{}", bv.to_string());
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
///
/// // reset bitvector to empty
/// bv.clear();
/// println!("{}", bv.to_string());
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
/// ```
#[stable]
Expand Down Expand Up @@ -1881,10 +1881,10 @@ mod tests {
#[test]
fn test_to_str() {
let zerolen = Bitv::new();
assert_eq!(zerolen.to_string(), "");
assert_eq!(format!("{:?}", zerolen), "");

let eightbits = Bitv::from_elem(8u, false);
assert_eq!(eightbits.to_string(), "00000000")
assert_eq!(format!("{:?}", eightbits), "00000000")
}

#[test]
Expand All @@ -1910,7 +1910,7 @@ mod tests {
let mut b = Bitv::from_elem(2, false);
b.set(0, true);
b.set(1, false);
assert_eq!(b.to_string(), "10");
assert_eq!(format!("{:?}", b), "10");
assert!(!b.none() && !b.all());
}

Expand Down Expand Up @@ -2245,7 +2245,7 @@ mod tests {
fn test_from_bytes() {
let bitv = Bitv::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
let str = concat!("10110110", "00000000", "11111111");
assert_eq!(bitv.to_string(), str);
assert_eq!(format!("{:?}", bitv), str);
}

#[test]
Expand All @@ -2264,7 +2264,7 @@ mod tests {
fn test_from_bools() {
let bools = vec![true, false, true, true];
let bitv: Bitv = bools.iter().map(|n| *n).collect();
assert_eq!(bitv.to_string(), "1011");
assert_eq!(format!("{:?}", bitv), "1011");
}

#[test]
Expand Down Expand Up @@ -2622,7 +2622,7 @@ mod bitv_set_test {
s.insert(10);
s.insert(50);
s.insert(2);
assert_eq!("{1, 2, 10, 50}", s.to_string());
assert_eq!("BitvSet {1u, 2u, 10u, 50u}", format!("{:?}", s));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
///
/// // count the number of occurrences of letters in the vec
/// for x in vec!["a","b","a","c","a","b"].iter() {
/// match count.entry(x) {
/// match count.entry(*x) {
/// Entry::Vacant(view) => {
/// view.insert(1);
/// },
Expand Down
6 changes: 3 additions & 3 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,9 @@ mod test {
set.insert(1);
set.insert(2);

let set_str = format!("{}", set);
let set_str = format!("{:?}", set);

assert!(set_str == "{1, 2}");
assert_eq!(format!("{}", empty), "{}");
assert_eq!(set_str, "BTreeSet {1i, 2i}");
assert_eq!(format!("{:?}", empty), "BTreeSet {}");
}
}
4 changes: 2 additions & 2 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,12 +1018,12 @@ mod tests {
#[test]
fn test_show() {
let list: DList<int> = range(0i, 10).collect();
assert!(list.to_string() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
assert_eq!(format!("{:?}", list), "DList [0i, 1i, 2i, 3i, 4i, 5i, 6i, 7i, 8i, 9i]");

let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
.map(|&s| s)
.collect();
assert!(list.to_string() == "[just, one, test, more]");
assert_eq!(format!("{:?}", list), "DList [\"just\", \"one\", \"test\", \"more\"]");
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![allow(unknown_features)]
#![feature(unsafe_destructor, slicing_syntax)]
#![feature(old_impl_check)]
#![feature(unboxed_closures)]
#![no_std]

#[macro_use]
Expand Down
10 changes: 2 additions & 8 deletions src/libcollections/ring_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,21 +1648,15 @@ mod tests {
assert_eq!(d.len(), 3u);
d.push_back(137);
assert_eq!(d.len(), 4u);
debug!("{}", d.front());
assert_eq!(*d.front().unwrap(), 42);
debug!("{}", d.back());
assert_eq!(*d.back().unwrap(), 137);
let mut i = d.pop_front();
debug!("{}", i);
assert_eq!(i, Some(42));
i = d.pop_back();
debug!("{}", i);
assert_eq!(i, Some(137));
i = d.pop_back();
debug!("{}", i);
assert_eq!(i, Some(137));
i = d.pop_back();
debug!("{}", i);
assert_eq!(i, Some(17));
assert_eq!(d.len(), 0u);
d.push_back(3);
Expand Down Expand Up @@ -2308,12 +2302,12 @@ mod tests {
#[test]
fn test_show() {
let ringbuf: RingBuf<int> = range(0i, 10).collect();
assert!(format!("{}", ringbuf) == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
assert_eq!(format!("{:?}", ringbuf), "RingBuf [0i, 1i, 2i, 3i, 4i, 5i, 6i, 7i, 8i, 9i]");

let ringbuf: RingBuf<&str> = vec!["just", "one", "test", "more"].iter()
.map(|&s| s)
.collect();
assert!(format!("{}", ringbuf) == "[just, one, test, more]");
assert_eq!(format!("{:?}", ringbuf), "RingBuf [\"just\", \"one\", \"test\", \"more\"]");
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@ pub trait ToString {
}

#[cfg(stage0)]
//NOTE(stage0): remove after stage0 snapshot
impl<T: fmt::Show> ToString for T {
fn to_string(&self) -> String {
use core::fmt::Writer;
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
//! // different type: just print it out unadorned.
//! match value_any.downcast_ref::<String>() {
//! Some(as_string) => {
//! println!("String ({}): {:?}", as_string.len(), as_string);
//! println!("String ({}): {}", as_string.len(), as_string);
//! }
//! None => {
//! println!("{}", value);
//! println!("{:?}", value);
//! }
//! }
//! }
Expand Down
19 changes: 14 additions & 5 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,12 @@ pub struct Arguments<'a> {
args: &'a [Argument<'a>],
}

#[cfg(stage0)]
//FIXME: remove after stage0 snapshot
impl<'a> Show for Arguments<'a> {
fn fmt(&self, fmt: &mut Formatter) -> Result {
write(fmt.buf, *self)
String::fmt(self, fmt)
}
}

#[cfg(not(stage0))]
impl<'a> String for Arguments<'a> {
fn fmt(&self, fmt: &mut Formatter) -> Result {
write(fmt.buf, *self)
Expand Down Expand Up @@ -863,14 +860,20 @@ impl<T: Show> Show for [T] {

impl<T: String> String for [T] {
fn fmt(&self, f: &mut Formatter) -> Result {
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "["));
}
let mut is_first = true;
for x in self.iter() {
if is_first {
is_first = false;
} else {
try!(write!(f, ", "));
}
try!(String::fmt(x, f))
try!(write!(f, "{}", *x))
}
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "]"));
}
Ok(())
}
Expand All @@ -882,6 +885,12 @@ impl Show for () {
}
}

impl String for () {
fn fmt(&self, f: &mut Formatter) -> Result {
f.pad("()")
}
}

impl<T: Copy + Show> Show for Cell<T> {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, "Cell {{ value: {:?} }}", self.get())
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ macro_rules! writeln {
($dst:expr, $fmt:expr) => (
write!($dst, concat!($fmt, "\n"))
);
($dst:expr, $fmt:expr, $($arg:expr),*) => (
write!($dst, concat!($fmt, "\n"), $($arg,)*)
($dst:expr, $fmt:expr, $($arg:tt)*) => (
write!($dst, concat!($fmt, "\n"), $($arg)*)
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
//! }
//! }
//! fn main() {
//! println!("{}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
//! println!("{}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
//! println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
//! println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
//! }
//! ```
//!
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<T> Option<T> {
/// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
/// // then consume *that* with `map`, leaving `num_as_str` on the stack.
/// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len());
/// println!("still can print num_as_str: {}", num_as_str);
/// println!("still can print num_as_str: {:?}", num_as_str);
/// ```
#[inline]
#[stable]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! use std::simd::f32x4;
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
//! println!("{}", a + b);
//! println!("{:?}", a + b);
//! }
//! ```
//!
Expand Down
10 changes: 5 additions & 5 deletions src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub trait Rng : Sized {
///
/// let mut v = [0u8; 13579];
/// thread_rng().fill_bytes(&mut v);
/// println!("{}", v.as_slice());
/// println!("{:?}", v.as_slice());
/// ```
fn fill_bytes(&mut self, dest: &mut [u8]) {
// this could, in theory, be done by transmuting dest to a
Expand Down Expand Up @@ -176,7 +176,7 @@ pub trait Rng : Sized {
/// let mut rng = thread_rng();
/// let x: uint = rng.gen();
/// println!("{}", x);
/// println!("{}", rng.gen::<(f64, bool)>());
/// println!("{:?}", rng.gen::<(f64, bool)>());
/// ```
#[inline(always)]
fn gen<T: Rand>(&mut self) -> T {
Expand All @@ -194,8 +194,8 @@ pub trait Rng : Sized {
/// let mut rng = thread_rng();
/// let x = rng.gen_iter::<uint>().take(10).collect::<Vec<uint>>();
/// println!("{}", x);
/// println!("{}", rng.gen_iter::<(f64, bool)>().take(5)
/// .collect::<Vec<(f64, bool)>>());
/// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5)
/// .collect::<Vec<(f64, bool)>>());
/// ```
fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
Generator { rng: self }
Expand Down Expand Up @@ -268,7 +268,7 @@ pub trait Rng : Sized {
///
/// let choices = [1i, 2, 4, 8, 16, 32];
/// let mut rng = thread_rng();
/// println!("{}", rng.choose(&choices));
/// println!("{:?}", rng.choose(&choices));
/// # // uncomment when slicing syntax is stable
/// //assert_eq!(rng.choose(choices.index(&(0..0))), None);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/libregex/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ macro_rules! regex {
($re:expr) => (
match ::regex::Regex::new($re) {
Ok(re) => re,
Err(err) => panic!("{}", err),
Err(err) => panic!("{:?}", err),
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libregex/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ macro_rules! mat {
sgot = &sgot[..expected.len()]
}
if expected != sgot {
panic!("For RE '{}' against '{}', expected '{}' but got '{}'",
panic!("For RE '{}' against '{}', expected '{:?}' but got '{:?}'",
$re, text, expected, sgot);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a> CrateReader<'a> {
match i.node {
ast::ViewItemExternCrate(ident, ref path_opt, id) => {
let ident = token::get_ident(ident);
debug!("resolving extern crate stmt. ident: {} path_opt: {}",
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
ident, path_opt);
let name = match *path_opt {
Some((ref path_str, _)) => {
Expand Down
Loading

4 comments on commit 4b4ef71

@bors
Copy link
Contributor

@bors bors commented on 4b4ef71 Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at alexcrichton@4b4ef71

@bors
Copy link
Contributor

@bors bors commented on 4b4ef71 Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/rollup = 4b4ef71 into auto

@bors
Copy link
Contributor

@bors bors commented on 4b4ef71 Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "37cb613be1df2c9bb0cf567c3e1b3c22ac5a4f93"}

@bors
Copy link
Contributor

@bors bors commented on 4b4ef71 Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/rollup = 4b4ef71 merged ok, testing candidate = 37cb613

Please sign in to comment.