1
Fork 0

std: Change assert_eq!() to use {} instead of {:?}

Formatting via reflection has been a little questionable for some time now, and
it's a little unfortunate that one of the standard macros will silently use
reflection when you weren't expecting it. This adds small bits of code bloat to
libraries, as well as not always being necessary. In light of this information,
this commit switches assert_eq!() to using {} in the error message instead of
{:?}.

In updating existing code, there were a few error cases that I encountered:

* It's impossible to define Show for [T, ..N]. I think DST will alleviate this
  because we can define Show for [T].
* A few types here and there just needed a #[deriving(Show)]
* Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
* `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
  I don't think this is much of a regression though because {:?} on paths looks
  awful (it's a byte array).

Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
significant for smaller binaries.
This commit is contained in:
Alex Crichton 2014-02-28 01:23:06 -08:00
parent 123eb4ebea
commit 02882fbd7e
97 changed files with 354 additions and 301 deletions

View file

@ -384,7 +384,7 @@ the trailing underscore is a workaround for issue #5898 and will be removed.
~~~ ~~~
let mut ys = [1, 2, 3, 4, 5]; let mut ys = [1, 2, 3, 4, 5];
ys.mut_iter().reverse_(); ys.mut_iter().reverse_();
assert_eq!(ys, [5, 4, 3, 2, 1]); assert!(ys == [5, 4, 3, 2, 1]);
~~~ ~~~
## Random-access iterators ## Random-access iterators

View file

@ -1688,7 +1688,7 @@ let x = Rc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
let y = x.clone(); // a new owner let y = x.clone(); // a new owner
let z = x; // this moves `x` into `z`, rather than creating a new owner let z = x; // this moves `x` into `z`, rather than creating a new owner
assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); assert!(*z.borrow() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
// the variable is mutable, but not the contents of the box // the variable is mutable, but not the contents of the box
let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);
@ -1707,7 +1707,7 @@ let x = Gc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
let y = x; // does not perform a move, unlike with `Rc` let y = x; // does not perform a move, unlike with `Rc`
let z = x; let z = x;
assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); assert!(*z.borrow() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
~~~ ~~~
With shared ownership, mutability cannot be inherited so the boxes are always immutable. However, With shared ownership, mutability cannot be inherited so the boxes are always immutable. However,

View file

@ -1542,7 +1542,7 @@ mod tests {
let mut b = a.clone(); let mut b = a.clone();
assert_eq!(&a, &b); assert!(a == b);
assert!(b.remove(&1)); assert!(b.remove(&1));
assert!(a.contains(&1)); assert!(a.contains(&1));
@ -1561,7 +1561,7 @@ mod tests {
let mut r = rng(); let mut r = rng();
let mut bitv = 0 as uint; let mut bitv = 0 as uint;
b.iter(|| { b.iter(|| {
bitv |= (1 << ((r.next_u32() as uint) % uint::BITS)); bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
&bitv &bitv
}) })
} }

View file

@ -982,11 +982,11 @@ mod tests {
fn test_eq() { fn test_eq() {
let mut n: DList<u8> = list_from([]); let mut n: DList<u8> = list_from([]);
let mut m = list_from([]); let mut m = list_from([]);
assert_eq!(&n, &m); assert!(n == m);
n.push_front(1); n.push_front(1);
assert!(n != m); assert!(n != m);
m.push_back(1); m.push_back(1);
assert_eq!(&n, &m); assert!(n == m);
let n = list_from([2,3,4]); let n = list_from([2,3,4]);
let m = list_from([1,2,3]); let m = list_from([1,2,3]);

View file

@ -141,7 +141,7 @@ mod test {
use enum_set::{EnumSet, CLike}; use enum_set::{EnumSet, CLike};
#[deriving(Eq)] #[deriving(Eq, Show)]
#[repr(uint)] #[repr(uint)]
enum Foo { enum Foo {
A, B, C A, B, C

View file

@ -1065,7 +1065,7 @@ mod test_map {
let mut observed = 0; let mut observed = 0;
for (k, v) in m.iter() { for (k, v) in m.iter() {
assert_eq!(*v, *k * 2); assert_eq!(*v, *k * 2);
observed |= (1 << *k); observed |= 1 << *k;
} }
assert_eq!(observed, 0xFFFF_FFFF); assert_eq!(observed, 0xFFFF_FFFF);
} }
@ -1293,7 +1293,7 @@ mod test_set {
} }
let mut observed = 0; let mut observed = 0;
for k in a.iter() { for k in a.iter() {
observed |= (1 << *k); observed |= 1 << *k;
} }
assert_eq!(observed, 0xFFFF_FFFF); assert_eq!(observed, 0xFFFF_FFFF);
} }

View file

@ -153,7 +153,7 @@ mod tests {
#[test] #[test]
fn test_from_vec_empty() { fn test_from_vec_empty() {
let empty : list::List<int> = List::from_vec([]); let empty : list::List<int> = List::from_vec([]);
assert_eq!(empty, Nil::<int>); assert!(empty == Nil::<int>);
} }
#[test] #[test]
@ -222,8 +222,8 @@ mod tests {
#[test] #[test]
fn test_append() { fn test_append() {
assert_eq!(List::from_vec([1, 2, 3, 4]), assert!(List::from_vec([1, 2, 3, 4]) ==
List::from_vec([1, 2]).append(List::from_vec([3, 4]))); List::from_vec([1, 2]).append(List::from_vec([3, 4])));
} }
#[test] #[test]
@ -232,6 +232,6 @@ mod tests {
let new_list = list.unshift(0); let new_list = list.unshift(0);
assert_eq!(list.len(), 1u); assert_eq!(list.len(), 1u);
assert_eq!(new_list.len(), 2u); assert_eq!(new_list.len(), 2u);
assert_eq!(new_list, List::from_vec([0, 1])); assert!(new_list == List::from_vec([0, 1]));
} }
} }

View file

@ -277,7 +277,7 @@ mod tests {
fn assert_opt_eq<V: Eq>(opt: Option<&V>, v: V) { fn assert_opt_eq<V: Eq>(opt: Option<&V>, v: V) {
assert!(opt.is_some()); assert!(opt.is_some());
assert_eq!(opt.unwrap(), &v); assert!(opt.unwrap() == &v);
} }
#[test] #[test]

View file

@ -409,6 +409,7 @@ mod tests {
use deque::Deque; use deque::Deque;
use std::clone::Clone; use std::clone::Clone;
use std::cmp::Eq; use std::cmp::Eq;
use std::fmt::Show;
use super::RingBuf; use super::RingBuf;
#[test] #[test]
@ -493,7 +494,7 @@ mod tests {
} }
#[cfg(test)] #[cfg(test)]
fn test_parameterized<T:Clone + Eq>(a: T, b: T, c: T, d: T) { fn test_parameterized<T:Clone + Eq + Show>(a: T, b: T, c: T, d: T) {
let mut deq = RingBuf::new(); let mut deq = RingBuf::new();
assert_eq!(deq.len(), 0); assert_eq!(deq.len(), 0);
deq.push_front(a.clone()); deq.push_front(a.clone());
@ -578,21 +579,21 @@ mod tests {
}) })
} }
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
enum Taggy { enum Taggy {
One(int), One(int),
Two(int, int), Two(int, int),
Three(int, int, int), Three(int, int, int),
} }
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
enum Taggypar<T> { enum Taggypar<T> {
Onepar(int), Onepar(int),
Twopar(int, int), Twopar(int, int),
Threepar(int, int, int), Threepar(int, int, int),
} }
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
struct RecCy { struct RecCy {
x: int, x: int,
y: int, y: int,
@ -812,7 +813,7 @@ mod tests {
#[test] #[test]
fn test_eq() { fn test_eq() {
let mut d = RingBuf::new(); let mut d = RingBuf::new();
assert_eq!(&d, &RingBuf::with_capacity(0)); assert!(d == RingBuf::with_capacity(0));
d.push_front(137); d.push_front(137);
d.push_front(17); d.push_front(17);
d.push_front(42); d.push_front(42);
@ -822,11 +823,11 @@ mod tests {
e.push_back(17); e.push_back(17);
e.push_back(137); e.push_back(137);
e.push_back(137); e.push_back(137);
assert_eq!(&e, &d); assert!(&e == &d);
e.pop_back(); e.pop_back();
e.push_back(0); e.push_back(0);
assert!(e != d); assert!(e != d);
e.clear(); e.clear();
assert_eq!(e, RingBuf::new()); assert!(e == RingBuf::new());
} }
} }

View file

@ -1361,7 +1361,7 @@ mod tests {
aliases: ~[] }]; aliases: ~[] }];
let verbose = reqopt("b", "banana", "some bananas", "VAL"); let verbose = reqopt("b", "banana", "some bananas", "VAL");
assert_eq!(verbose.long_to_short(), short); assert!(verbose.long_to_short() == short);
} }
#[test] #[test]

View file

@ -829,7 +829,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
} }
/// A Sign is a `BigInt`'s composing element. /// A Sign is a `BigInt`'s composing element.
#[deriving(Eq, Clone)] #[deriving(Eq, Clone, Show)]
pub enum Sign { Minus, Zero, Plus } pub enum Sign { Minus, Zero, Plus }
impl Ord for Sign { impl Ord for Sign {

View file

@ -215,7 +215,7 @@ mod test {
#[test] #[test]
fn test_minimize1() { fn test_minimize1() {
let res = minimize_rpaths([~"rpath1", ~"rpath2", ~"rpath1"]); let res = minimize_rpaths([~"rpath1", ~"rpath2", ~"rpath1"]);
assert_eq!(res.as_slice(), [~"rpath1", ~"rpath2"]); assert!(res.as_slice() == [~"rpath1", ~"rpath2"]);
} }
#[test] #[test]
@ -224,7 +224,7 @@ mod test {
~"1a", ~"4a", ~"1a", ~"1a", ~"4a", ~"1a",
~"2", ~"3", ~"4a", ~"2", ~"3", ~"4a",
~"3"]); ~"3"]);
assert_eq!(res.as_slice(), [~"1a", ~"2", ~"4a", ~"3"]); assert!(res.as_slice() == [~"1a", ~"2", ~"4a", ~"3"]);
} }
#[test] #[test]

View file

@ -1468,7 +1468,7 @@ fn roundtrip(in_item: Option<@ast::Item>) {
let ebml_doc = reader::Doc(wr.get_ref()); let ebml_doc = reader::Doc(wr.get_ref());
let out_item = decode_item_ast(ebml_doc); let out_item = decode_item_ast(ebml_doc);
assert_eq!(in_item, out_item); assert!(in_item == out_item);
} }
#[test] #[test]

View file

@ -349,19 +349,19 @@ mod test {
start_data: N, start_data: N,
expected_incoming: &[(E,N)], expected_incoming: &[(E,N)],
expected_outgoing: &[(E,N)]) { expected_outgoing: &[(E,N)]) {
assert_eq!(graph.node_data(start_index), &start_data); assert!(graph.node_data(start_index) == &start_data);
let mut counter = 0; let mut counter = 0;
graph.each_incoming_edge(start_index, |edge_index, edge| { graph.each_incoming_edge(start_index, |edge_index, edge| {
assert_eq!(graph.edge_data(edge_index), &edge.data); assert!(graph.edge_data(edge_index) == &edge.data);
assert!(counter < expected_incoming.len()); assert!(counter < expected_incoming.len());
debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
counter, expected_incoming[counter], edge_index, edge); counter, expected_incoming[counter], edge_index, edge);
match expected_incoming[counter] { match expected_incoming[counter] {
(ref e, ref n) => { (ref e, ref n) => {
assert_eq!(e, &edge.data); assert!(e == &edge.data);
assert_eq!(n, graph.node_data(edge.source)); assert!(n == graph.node_data(edge.source));
assert_eq!(start_index, edge.target); assert!(start_index == edge.target);
} }
} }
counter += 1; counter += 1;
@ -371,15 +371,15 @@ mod test {
let mut counter = 0; let mut counter = 0;
graph.each_outgoing_edge(start_index, |edge_index, edge| { graph.each_outgoing_edge(start_index, |edge_index, edge| {
assert_eq!(graph.edge_data(edge_index), &edge.data); assert!(graph.edge_data(edge_index) == &edge.data);
assert!(counter < expected_outgoing.len()); assert!(counter < expected_outgoing.len());
debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
counter, expected_outgoing[counter], edge_index, edge); counter, expected_outgoing[counter], edge_index, edge);
match expected_outgoing[counter] { match expected_outgoing[counter] {
(ref e, ref n) => { (ref e, ref n) => {
assert_eq!(e, &edge.data); assert!(e == &edge.data);
assert_eq!(start_index, edge.source); assert!(start_index == edge.source);
assert_eq!(n, graph.node_data(edge.target)); assert!(n == graph.node_data(edge.target));
} }
} }
counter += 1; counter += 1;

View file

@ -25,7 +25,7 @@ use std::cast;
use std::libc::{c_uint}; use std::libc::{c_uint};
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
pub struct Type { pub struct Type {
priv rf: TypeRef priv rf: TypeRef
} }

View file

@ -761,7 +761,7 @@ impl RegionVarBindings {
// ______________________________________________________________________ // ______________________________________________________________________
#[deriving(Eq)] #[deriving(Eq, Show)]
enum Classification { Expanding, Contracting } enum Classification { Expanding, Contracting }
enum VarValue { NoValue, Value(Region), ErrorValue } enum VarValue { NoValue, Value(Region), ErrorValue }

View file

@ -1588,20 +1588,20 @@ mod tests {
use std::io; use std::io;
use collections::TreeMap; use collections::TreeMap;
#[deriving(Eq, Encodable, Decodable)] #[deriving(Eq, Encodable, Decodable, Show)]
enum Animal { enum Animal {
Dog, Dog,
Frog(~str, int) Frog(~str, int)
} }
#[deriving(Eq, Encodable, Decodable)] #[deriving(Eq, Encodable, Decodable, Show)]
struct Inner { struct Inner {
a: (), a: (),
b: uint, b: uint,
c: ~[~str], c: ~[~str],
} }
#[deriving(Eq, Encodable, Decodable)] #[deriving(Eq, Encodable, Decodable, Show)]
struct Outer { struct Outer {
inner: ~[Inner], inner: ~[Inner],
} }

View file

@ -167,7 +167,7 @@ mod tests {
use prelude::*; use prelude::*;
use super::*; use super::*;
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Test; struct Test;
static TEST: &'static str = "Test"; static TEST: &'static str = "Test";

View file

@ -475,7 +475,7 @@ mod tests {
use char::from_u32; use char::from_u32;
macro_rules! v2ascii ( macro_rules! v2ascii (
( [$($e:expr),*]) => ( [$(Ascii{chr:$e}),*]); ( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]);
(&[$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); (&[$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]);
(~[$($e:expr),*]) => (~[$(Ascii{chr:$e}),*]); (~[$($e:expr),*]) => (~[$(Ascii{chr:$e}),*]);
) )

View file

@ -293,9 +293,9 @@ mod tests {
#[test] #[test]
fn test_totalord() { fn test_totalord() {
assert_eq!(true.cmp(&true), Equal); assert!(true.cmp(&true) == Equal);
assert_eq!(false.cmp(&false), Equal); assert!(false.cmp(&false) == Equal);
assert_eq!(true.cmp(&false), Greater); assert!(true.cmp(&false) == Greater);
assert_eq!(false.cmp(&true), Less); assert!(false.cmp(&true) == Less);
} }
} }

View file

@ -10,12 +10,13 @@
//! Types dealing with dynamic mutability //! Types dealing with dynamic mutability
use cast;
use clone::{Clone, DeepClone}; use clone::{Clone, DeepClone};
use cmp::Eq; use cmp::Eq;
use fmt;
use kinds::{marker, Pod};
use ops::Drop; use ops::Drop;
use option::{None, Option, Some}; use option::{None, Option, Some};
use cast;
use kinds::{marker, Pod};
/// A mutable memory location that admits only `Pod` data. /// A mutable memory location that admits only `Pod` data.
pub struct Cell<T> { pub struct Cell<T> {
@ -61,6 +62,12 @@ impl<T:Eq + Pod> Eq for Cell<T> {
} }
} }
impl<T: fmt::Show> fmt::Show for Cell<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, r"Cell \{ value: {} \}", self.value)
}
}
/// A mutable memory location with dynamically checked borrow rules /// A mutable memory location with dynamically checked borrow rules
pub struct RefCell<T> { pub struct RefCell<T> {
priv value: T, priv value: T,

View file

@ -72,7 +72,7 @@ totaleq_impl!(uint)
totaleq_impl!(char) totaleq_impl!(char)
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
pub enum Ordering { Less = -1, Equal = 0, Greater = 1 } pub enum Ordering { Less = -1, Equal = 0, Greater = 1 }
/// Trait for types that form a total order /// Trait for types that form a total order

View file

@ -313,7 +313,7 @@ pub struct Chan<T> {
/// This enumeration is the list of the possible reasons that try_recv could not /// This enumeration is the list of the possible reasons that try_recv could not
/// return data when called. /// return data when called.
#[deriving(Eq, Clone)] #[deriving(Eq, Clone, Show)]
pub enum TryRecvResult<T> { pub enum TryRecvResult<T> {
/// This channel is currently empty, but the sender(s) have not yet /// This channel is currently empty, but the sender(s) have not yet
/// disconnected, so data may yet become available. /// disconnected, so data may yet become available.

View file

@ -657,7 +657,7 @@ mod tests {
fn same(fmt: &'static str, p: ~[Piece<'static>]) { fn same(fmt: &'static str, p: ~[Piece<'static>]) {
let mut parser = Parser::new(fmt); let mut parser = Parser::new(fmt);
assert_eq!(p, parser.collect()); assert!(p == parser.collect());
} }
fn fmtdflt() -> FormatSpec<'static> { fn fmtdflt() -> FormatSpec<'static> {

View file

@ -444,7 +444,7 @@ extern "rust-intrinsic" {
/// `TypeId` represents a globally unique identifier for a type /// `TypeId` represents a globally unique identifier for a type
#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and #[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
// middle/lang_items.rs // middle/lang_items.rs
#[deriving(Eq, Hash)] #[deriving(Eq, Hash, Show)]
#[cfg(not(test))] #[cfg(not(test))]
pub struct TypeId { pub struct TypeId {
priv t: u64, priv t: u64,

View file

@ -391,21 +391,21 @@ mod test {
let mut buf = [0, 0, 0]; let mut buf = [0, 0, 0];
let nread = reader.read(buf); let nread = reader.read(buf);
assert_eq!(Ok(2), nread); assert_eq!(Ok(2), nread);
assert_eq!([0, 1, 0], buf); assert_eq!(buf.as_slice(), &[0, 1, 0]);
let mut buf = [0]; let mut buf = [0];
let nread = reader.read(buf); let nread = reader.read(buf);
assert_eq!(Ok(1), nread); assert_eq!(Ok(1), nread);
assert_eq!([2], buf); assert_eq!(buf.as_slice(), &[2]);
let mut buf = [0, 0, 0]; let mut buf = [0, 0, 0];
let nread = reader.read(buf); let nread = reader.read(buf);
assert_eq!(Ok(1), nread); assert_eq!(Ok(1), nread);
assert_eq!([3, 0, 0], buf); assert_eq!(buf.as_slice(), &[3, 0, 0]);
let nread = reader.read(buf); let nread = reader.read(buf);
assert_eq!(Ok(1), nread); assert_eq!(Ok(1), nread);
assert_eq!([4, 0, 0], buf); assert_eq!(buf.as_slice(), &[4, 0, 0]);
assert!(reader.read(buf).is_err()); assert!(reader.read(buf).is_err());
} }
@ -416,35 +416,35 @@ mod test {
let mut writer = BufferedWriter::with_capacity(2, inner); let mut writer = BufferedWriter::with_capacity(2, inner);
writer.write([0, 1]).unwrap(); writer.write([0, 1]).unwrap();
assert_eq!([], writer.get_ref().get_ref()); assert_eq!(writer.get_ref().get_ref(), &[]);
writer.write([2]).unwrap(); writer.write([2]).unwrap();
assert_eq!([0, 1], writer.get_ref().get_ref()); assert_eq!(writer.get_ref().get_ref(), &[0, 1]);
writer.write([3]).unwrap(); writer.write([3]).unwrap();
assert_eq!([0, 1], writer.get_ref().get_ref()); assert_eq!(writer.get_ref().get_ref(), &[0, 1]);
writer.flush().unwrap(); writer.flush().unwrap();
assert_eq!([0, 1, 2, 3], writer.get_ref().get_ref()); assert_eq!(&[0, 1, 2, 3], writer.get_ref().get_ref());
writer.write([4]).unwrap(); writer.write([4]).unwrap();
writer.write([5]).unwrap(); writer.write([5]).unwrap();
assert_eq!([0, 1, 2, 3], writer.get_ref().get_ref()); assert_eq!(&[0, 1, 2, 3], writer.get_ref().get_ref());
writer.write([6]).unwrap(); writer.write([6]).unwrap();
assert_eq!([0, 1, 2, 3, 4, 5], assert_eq!(&[0, 1, 2, 3, 4, 5],
writer.get_ref().get_ref()); writer.get_ref().get_ref());
writer.write([7, 8]).unwrap(); writer.write([7, 8]).unwrap();
assert_eq!([0, 1, 2, 3, 4, 5, 6], assert_eq!(&[0, 1, 2, 3, 4, 5, 6],
writer.get_ref().get_ref()); writer.get_ref().get_ref());
writer.write([9, 10, 11]).unwrap(); writer.write([9, 10, 11]).unwrap();
assert_eq!([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], assert_eq!(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
writer.get_ref().get_ref()); writer.get_ref().get_ref());
writer.flush().unwrap(); writer.flush().unwrap();
assert_eq!([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], assert_eq!(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
writer.get_ref().get_ref()); writer.get_ref().get_ref());
} }
@ -452,9 +452,9 @@ mod test {
fn test_buffered_writer_inner_flushes() { fn test_buffered_writer_inner_flushes() {
let mut w = BufferedWriter::with_capacity(3, MemWriter::new()); let mut w = BufferedWriter::with_capacity(3, MemWriter::new());
w.write([0, 1]).unwrap(); w.write([0, 1]).unwrap();
assert_eq!([], w.get_ref().get_ref()); assert_eq!(&[], w.get_ref().get_ref());
let w = w.unwrap(); let w = w.unwrap();
assert_eq!([0, 1], w.get_ref()); assert_eq!(&[0, 1], w.get_ref());
} }
// This is just here to make sure that we don't infinite loop in the // This is just here to make sure that we don't infinite loop in the
@ -495,20 +495,20 @@ mod test {
fn test_line_buffer() { fn test_line_buffer() {
let mut writer = LineBufferedWriter::new(MemWriter::new()); let mut writer = LineBufferedWriter::new(MemWriter::new());
writer.write([0]).unwrap(); writer.write([0]).unwrap();
assert_eq!(writer.get_ref().get_ref(), []); assert_eq!(writer.get_ref().get_ref(), &[]);
writer.write([1]).unwrap(); writer.write([1]).unwrap();
assert_eq!(writer.get_ref().get_ref(), []); assert_eq!(writer.get_ref().get_ref(), &[]);
writer.flush().unwrap(); writer.flush().unwrap();
assert_eq!(writer.get_ref().get_ref(), [0, 1]); assert_eq!(writer.get_ref().get_ref(), &[0, 1]);
writer.write([0, '\n' as u8, 1, '\n' as u8, 2]).unwrap(); writer.write([0, '\n' as u8, 1, '\n' as u8, 2]).unwrap();
assert_eq!(writer.get_ref().get_ref(), assert_eq!(writer.get_ref().get_ref(),
[0, 1, 0, '\n' as u8, 1, '\n' as u8]); &[0, 1, 0, '\n' as u8, 1, '\n' as u8]);
writer.flush().unwrap(); writer.flush().unwrap();
assert_eq!(writer.get_ref().get_ref(), assert_eq!(writer.get_ref().get_ref(),
[0, 1, 0, '\n' as u8, 1, '\n' as u8, 2]); &[0, 1, 0, '\n' as u8, 1, '\n' as u8, 2]);
writer.write([3, '\n' as u8]).unwrap(); writer.write([3, '\n' as u8]).unwrap();
assert_eq!(writer.get_ref().get_ref(), assert_eq!(writer.get_ref().get_ref(),
[0, 1, 0, '\n' as u8, 1, '\n' as u8, 2, 3, '\n' as u8]); &[0, 1, 0, '\n' as u8, 1, '\n' as u8, 2, 3, '\n' as u8]);
} }
#[test] #[test]

View file

@ -216,7 +216,7 @@ impl Buffer for MemReader {
/// let mut w = BufWriter::new(buf); /// let mut w = BufWriter::new(buf);
/// w.write([0, 1, 2]); /// w.write([0, 1, 2]);
/// } /// }
/// assert_eq!(buf, [0, 1, 2, 0]); /// assert!(buf == [0, 1, 2, 0]);
/// ``` /// ```
pub struct BufWriter<'a> { pub struct BufWriter<'a> {
priv buf: &'a mut [u8], priv buf: &'a mut [u8],
@ -348,24 +348,24 @@ mod test {
writer.write([1, 2, 3]).unwrap(); writer.write([1, 2, 3]).unwrap();
writer.write([4, 5, 6, 7]).unwrap(); writer.write([4, 5, 6, 7]).unwrap();
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
assert_eq!(writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7]); assert_eq!(writer.get_ref(), &[0, 1, 2, 3, 4, 5, 6, 7]);
writer.seek(0, SeekSet).unwrap(); writer.seek(0, SeekSet).unwrap();
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
writer.write([3, 4]).unwrap(); writer.write([3, 4]).unwrap();
assert_eq!(writer.get_ref(), [3, 4, 2, 3, 4, 5, 6, 7]); assert_eq!(writer.get_ref(), &[3, 4, 2, 3, 4, 5, 6, 7]);
writer.seek(1, SeekCur).unwrap(); writer.seek(1, SeekCur).unwrap();
writer.write([0, 1]).unwrap(); writer.write([0, 1]).unwrap();
assert_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 7]); assert_eq!(writer.get_ref(), &[3, 4, 2, 0, 1, 5, 6, 7]);
writer.seek(-1, SeekEnd).unwrap(); writer.seek(-1, SeekEnd).unwrap();
writer.write([1, 2]).unwrap(); writer.write([1, 2]).unwrap();
assert_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 1, 2]); assert_eq!(writer.get_ref(), &[3, 4, 2, 0, 1, 5, 6, 1, 2]);
writer.seek(1, SeekEnd).unwrap(); writer.seek(1, SeekEnd).unwrap();
writer.write([1]).unwrap(); writer.write([1]).unwrap();
assert_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1]); assert_eq!(writer.get_ref(), &[3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1]);
} }
#[test] #[test]
@ -380,7 +380,7 @@ mod test {
writer.write([4, 5, 6, 7]).unwrap(); writer.write([4, 5, 6, 7]).unwrap();
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
} }
assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7]); assert_eq!(buf.as_slice(), &[0, 1, 2, 3, 4, 5, 6, 7]);
} }
#[test] #[test]
@ -408,7 +408,7 @@ mod test {
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
} }
assert_eq!(buf, [1, 3, 2, 0, 0, 0, 0, 4]); assert_eq!(buf.as_slice(), &[1, 3, 2, 0, 0, 0, 0, 4]);
} }
#[test] #[test]
@ -432,13 +432,13 @@ mod test {
let mut buf = [0]; let mut buf = [0];
assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(buf), Ok(1));
assert_eq!(reader.tell(), Ok(1)); assert_eq!(reader.tell(), Ok(1));
assert_eq!(buf, [0]); assert_eq!(buf.as_slice(), &[0]);
let mut buf = [0, ..4]; let mut buf = [0, ..4];
assert_eq!(reader.read(buf), Ok(4)); assert_eq!(reader.read(buf), Ok(4));
assert_eq!(reader.tell(), Ok(5)); assert_eq!(reader.tell(), Ok(5));
assert_eq!(buf, [1, 2, 3, 4]); assert_eq!(buf.as_slice(), &[1, 2, 3, 4]);
assert_eq!(reader.read(buf), Ok(3)); assert_eq!(reader.read(buf), Ok(3));
assert_eq!(buf.slice(0, 3), [5, 6, 7]); assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
assert!(reader.read(buf).is_err()); assert!(reader.read(buf).is_err());
let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]); let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]);
assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]);
@ -456,13 +456,13 @@ mod test {
let mut buf = [0]; let mut buf = [0];
assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(buf), Ok(1));
assert_eq!(reader.tell(), Ok(1)); assert_eq!(reader.tell(), Ok(1));
assert_eq!(buf, [0]); assert_eq!(buf.as_slice(), &[0]);
let mut buf = [0, ..4]; let mut buf = [0, ..4];
assert_eq!(reader.read(buf), Ok(4)); assert_eq!(reader.read(buf), Ok(4));
assert_eq!(reader.tell(), Ok(5)); assert_eq!(reader.tell(), Ok(5));
assert_eq!(buf, [1, 2, 3, 4]); assert_eq!(buf.as_slice(), &[1, 2, 3, 4]);
assert_eq!(reader.read(buf), Ok(3)); assert_eq!(reader.read(buf), Ok(3));
assert_eq!(buf.slice(0, 3), [5, 6, 7]); assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
assert!(reader.read(buf).is_err()); assert!(reader.read(buf).is_err());
let mut reader = BufReader::new(in_buf); let mut reader = BufReader::new(in_buf);
assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]);

View file

@ -1286,7 +1286,7 @@ pub enum FileAccess {
} }
/// Different kinds of files which can be identified by a call to stat /// Different kinds of files which can be identified by a call to stat
#[deriving(Eq)] #[deriving(Eq, Show)]
pub enum FileType { pub enum FileType {
/// This is a normal file, corresponding to `S_IFREG` /// This is a normal file, corresponding to `S_IFREG`
TypeFile, TypeFile,

View file

@ -111,7 +111,7 @@ mod test {
Ok(MemReader::new(~[0, 1, 2, 3])); Ok(MemReader::new(~[0, 1, 2, 3]));
let mut buf = [0, 0]; let mut buf = [0, 0];
reader.read(buf).unwrap(); reader.read(buf).unwrap();
assert_eq!(buf, [0, 1]); assert_eq!(buf.as_slice(), &[0, 1]);
} }
#[test] #[test]

View file

@ -31,7 +31,7 @@ use vec::{ImmutableVector, OwnedVector};
/// Signals that can be sent and received /// Signals that can be sent and received
#[repr(int)] #[repr(int)]
#[deriving(Eq, Hash)] #[deriving(Eq, Hash, Show)]
pub enum Signum { pub enum Signum {
/// Equivalent to SIGBREAK, delivered when the user presses Ctrl-Break. /// Equivalent to SIGBREAK, delivered when the user presses Ctrl-Break.
Break = 21i, Break = 21i,

View file

@ -983,7 +983,7 @@ impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
} }
/// `MinMaxResult` is an enum returned by `min_max`. See `OrdIterator::min_max` for more detail. /// `MinMaxResult` is an enum returned by `min_max`. See `OrdIterator::min_max` for more detail.
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
pub enum MinMaxResult<T> { pub enum MinMaxResult<T> {
/// Empty iterator /// Empty iterator
NoElements, NoElements,
@ -2507,7 +2507,7 @@ mod tests {
.collect::<~[uint]>(); .collect::<~[uint]>();
assert_eq!(n, xs.len()); assert_eq!(n, xs.len());
assert_eq!(xs, ys.as_slice()); assert_eq!(xs.as_slice(), ys.as_slice());
} }
#[test] #[test]
@ -2824,11 +2824,11 @@ mod tests {
assert_eq!(len, b.indexable()); assert_eq!(len, b.indexable());
let mut n = 0; let mut n = 0;
for (i, elt) in a.enumerate() { for (i, elt) in a.enumerate() {
assert_eq!(Some(elt), b.idx(i)); assert!(Some(elt) == b.idx(i));
n += 1; n += 1;
} }
assert_eq!(n, len); assert_eq!(n, len);
assert_eq!(None, b.idx(n)); assert!(None == b.idx(n));
// call recursively to check after picking off an element // call recursively to check after picking off an element
if len > 0 { if len > 0 {
b.next(); b.next();
@ -3051,7 +3051,7 @@ mod tests {
fn test_reverse() { fn test_reverse() {
let mut ys = [1, 2, 3, 4, 5]; let mut ys = [1, 2, 3, 4, 5];
ys.mut_iter().reverse_(); ys.mut_iter().reverse_();
assert_eq!(ys, [5, 4, 3, 2, 1]); assert!(ys == [5, 4, 3, 2, 1]);
} }
#[test] #[test]

View file

@ -224,7 +224,7 @@ macro_rules! assert_eq(
if !((*given_val == *expected_val) && if !((*given_val == *expected_val) &&
(*expected_val == *given_val)) { (*expected_val == *given_val)) {
fail!("assertion failed: `(left == right) && (right == left)` \ fail!("assertion failed: `(left == right) && (right == left)` \
(left: `{:?}`, right: `{:?}`)", *given_val, *expected_val) (left: `{}`, right: `{}`)", *given_val, *expected_val)
} }
}) })
) )

View file

@ -295,7 +295,7 @@ pub fn checked_next_power_of_two<T: Unsigned + Int>(n: T) -> Option<T> {
} }
/// Used for representing the classification of floating point numbers /// Used for representing the classification of floating point numbers
#[deriving(Eq)] #[deriving(Eq, Show)]
pub enum FPCategory { pub enum FPCategory {
/// "Not a Number", often obtained by dividing by zero /// "Not a Number", often obtained by dividing by zero
FPNaN, FPNaN,
@ -1075,7 +1075,7 @@ pub trait CheckedDiv: Div<Self, Self> {
/// Helper function for testing numeric operations /// Helper function for testing numeric operations
#[cfg(test)] #[cfg(test)]
pub fn test_num<T:Num + NumCast>(ten: T, two: T) { pub fn test_num<T:Num + NumCast + Show>(ten: T, two: T) {
assert_eq!(ten.add(&two), cast(12).unwrap()); assert_eq!(ten.add(&two), cast(12).unwrap());
assert_eq!(ten.sub(&two), cast(8).unwrap()); assert_eq!(ten.sub(&two), cast(8).unwrap());
assert_eq!(ten.mul(&two), cast(20).unwrap()); assert_eq!(ten.mul(&two), cast(20).unwrap());
@ -1650,7 +1650,7 @@ mod tests {
test_checked_next_power_of_two!(test_checked_next_power_of_two_u64, u64) test_checked_next_power_of_two!(test_checked_next_power_of_two_u64, u64)
test_checked_next_power_of_two!(test_checked_next_power_of_two_uint, uint) test_checked_next_power_of_two!(test_checked_next_power_of_two_uint, uint)
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Value { x: int } struct Value { x: int }
impl ToPrimitive for Value { impl ToPrimitive for Value {

View file

@ -1535,7 +1535,7 @@ mod tests {
let oldhome = getenv("HOME"); let oldhome = getenv("HOME");
setenv("HOME", "/home/MountainView"); setenv("HOME", "/home/MountainView");
assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); assert!(os::homedir() == Some(Path::new("/home/MountainView")));
setenv("HOME", ""); setenv("HOME", "");
assert!(os::homedir().is_none()); assert!(os::homedir().is_none());
@ -1556,16 +1556,16 @@ mod tests {
assert!(os::homedir().is_none()); assert!(os::homedir().is_none());
setenv("HOME", "/home/MountainView"); setenv("HOME", "/home/MountainView");
assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); assert!(os::homedir() == Some(Path::new("/home/MountainView")));
setenv("HOME", ""); setenv("HOME", "");
setenv("USERPROFILE", "/home/MountainView"); setenv("USERPROFILE", "/home/MountainView");
assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); assert!(os::homedir() == Some(Path::new("/home/MountainView")));
setenv("HOME", "/home/MountainView"); setenv("HOME", "/home/MountainView");
setenv("USERPROFILE", "/home/PaloAlto"); setenv("USERPROFILE", "/home/PaloAlto");
assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); assert!(os::homedir() == Some(Path::new("/home/MountainView")));
for s in oldhome.iter() { setenv("HOME", *s) } for s in oldhome.iter() { setenv("HOME", *s) }
for s in olduserprofile.iter() { setenv("USERPROFILE", *s) } for s in olduserprofile.iter() { setenv("USERPROFILE", *s) }

View file

@ -455,13 +455,13 @@ mod tests {
(s: $path:expr, $exp:expr) => ( (s: $path:expr, $exp:expr) => (
{ {
let path = $path; let path = $path;
assert_eq!(path.as_str(), Some($exp)); assert!(path.as_str() == Some($exp));
} }
); );
(v: $path:expr, $exp:expr) => ( (v: $path:expr, $exp:expr) => (
{ {
let path = $path; let path = $path;
assert_eq!(path.as_vec(), $exp); assert!(path.as_vec() == $exp);
} }
) )
) )
@ -484,7 +484,7 @@ mod tests {
t!(v: Path::new(b!("a/b/c", 0xff)), b!("a/b/c", 0xff)); t!(v: Path::new(b!("a/b/c", 0xff)), b!("a/b/c", 0xff));
t!(v: Path::new(b!(0xff, "/../foo", 0x80)), b!("foo", 0x80)); t!(v: Path::new(b!(0xff, "/../foo", 0x80)), b!("foo", 0x80));
let p = Path::new(b!("a/b/c", 0xff)); let p = Path::new(b!("a/b/c", 0xff));
assert_eq!(p.as_str(), None); assert!(p.as_str() == None);
t!(s: Path::new(""), "."); t!(s: Path::new(""), ".");
t!(s: Path::new("/"), "/"); t!(s: Path::new("/"), "/");
@ -509,19 +509,19 @@ mod tests {
t!(s: Path::new("foo/../../.."), "../.."); t!(s: Path::new("foo/../../.."), "../..");
t!(s: Path::new("foo/../../bar"), "../bar"); t!(s: Path::new("foo/../../bar"), "../bar");
assert_eq!(Path::new(b!("foo/bar")).into_vec(), b!("foo/bar").to_owned()); assert!(Path::new(b!("foo/bar")).into_vec() == b!("foo/bar").to_owned());
assert_eq!(Path::new(b!("/foo/../../bar")).into_vec(), assert!(Path::new(b!("/foo/../../bar")).into_vec() ==
b!("/bar").to_owned()); b!("/bar").to_owned());
let p = Path::new(b!("foo/bar", 0x80)); let p = Path::new(b!("foo/bar", 0x80));
assert_eq!(p.as_str(), None); assert!(p.as_str() == None);
} }
#[test] #[test]
fn test_opt_paths() { fn test_opt_paths() {
assert_eq!(Path::new_opt(b!("foo/bar", 0)), None); assert!(Path::new_opt(b!("foo/bar", 0)) == None);
t!(v: Path::new_opt(b!("foo/bar")).unwrap(), b!("foo/bar")); t!(v: Path::new_opt(b!("foo/bar")).unwrap(), b!("foo/bar"));
assert_eq!(Path::new_opt("foo/bar\0"), None); assert!(Path::new_opt("foo/bar\0") == None);
t!(s: Path::new_opt("foo/bar").unwrap(), "foo/bar"); t!(s: Path::new_opt("foo/bar").unwrap(), "foo/bar");
} }
@ -550,7 +550,7 @@ mod tests {
($path:expr, $disp:ident, $exp:expr) => ( ($path:expr, $disp:ident, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
assert_eq!(path.$disp().to_str(), ~$exp); assert!(path.$disp().to_str() == ~$exp);
} }
) )
) )
@ -566,14 +566,14 @@ mod tests {
{ {
let path = Path::new($path); let path = Path::new($path);
let mo = path.display().as_maybe_owned(); let mo = path.display().as_maybe_owned();
assert_eq!(mo.as_slice(), $exp); assert!(mo.as_slice() == $exp);
} }
); );
($path:expr, $exp:expr, filename) => ( ($path:expr, $exp:expr, filename) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let mo = path.filename_display().as_maybe_owned(); let mo = path.filename_display().as_maybe_owned();
assert_eq!(mo.as_slice(), $exp); assert!(mo.as_slice() == $exp);
} }
) )
) )
@ -593,9 +593,9 @@ mod tests {
{ {
let path = Path::new($path); let path = Path::new($path);
let f = format!("{}", path.display()); let f = format!("{}", path.display());
assert_eq!(f.as_slice(), $exp); assert!(f.as_slice() == $exp);
let f = format!("{}", path.filename_display()); let f = format!("{}", path.filename_display());
assert_eq!(f.as_slice(), $expf); assert!(f.as_slice() == $expf);
} }
) )
) )
@ -615,21 +615,21 @@ mod tests {
(s: $path:expr, $op:ident, $exp:expr) => ( (s: $path:expr, $op:ident, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
assert_eq!(path.$op(), ($exp).as_bytes()); assert!(path.$op() == ($exp).as_bytes());
} }
); );
(s: $path:expr, $op:ident, $exp:expr, opt) => ( (s: $path:expr, $op:ident, $exp:expr, opt) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let left = path.$op().map(|x| str::from_utf8(x).unwrap()); let left = path.$op().map(|x| str::from_utf8(x).unwrap());
assert_eq!(left, $exp); assert!(left == $exp);
} }
); );
(v: $path:expr, $op:ident, $exp:expr) => ( (v: $path:expr, $op:ident, $exp:expr) => (
{ {
let arg = $path; let arg = $path;
let path = Path::new(arg); let path = Path::new(arg);
assert_eq!(path.$op(), $exp); assert!(path.$op() == $exp);
} }
); );
) )
@ -703,7 +703,7 @@ mod tests {
let mut p1 = Path::new(path); let mut p1 = Path::new(path);
let p2 = p1.clone(); let p2 = p1.clone();
p1.push(join); p1.push(join);
assert_eq!(p1, p2.join(join)); assert!(p1 == p2.join(join));
} }
) )
) )
@ -722,7 +722,7 @@ mod tests {
let mut p = Path::new($path); let mut p = Path::new($path);
let push = Path::new($push); let push = Path::new($push);
p.push(&push); p.push(&push);
assert_eq!(p.as_str(), Some($exp)); assert!(p.as_str() == Some($exp));
} }
) )
) )
@ -742,14 +742,14 @@ mod tests {
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
p.push_many($push); p.push_many($push);
assert_eq!(p.as_str(), Some($exp)); assert!(p.as_str() == Some($exp));
} }
); );
(v: $path:expr, $push:expr, $exp:expr) => ( (v: $path:expr, $push:expr, $exp:expr) => (
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
p.push_many($push); p.push_many($push);
assert_eq!(p.as_vec(), $exp); assert!(p.as_vec() == $exp);
} }
) )
) )
@ -770,16 +770,16 @@ mod tests {
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
let result = p.pop(); let result = p.pop();
assert_eq!(p.as_str(), Some($left)); assert!(p.as_str() == Some($left));
assert_eq!(result, $right); assert!(result == $right);
} }
); );
(v: [$($path:expr),+], [$($left:expr),+], $right:expr) => ( (v: [$($path:expr),+], [$($left:expr),+], $right:expr) => (
{ {
let mut p = Path::new(b!($($path),+)); let mut p = Path::new(b!($($path),+));
let result = p.pop(); let result = p.pop();
assert_eq!(p.as_vec(), b!($($left),+)); assert!(p.as_vec() == b!($($left),+));
assert_eq!(result, $right); assert!(result == $right);
} }
) )
) )
@ -802,8 +802,8 @@ mod tests {
#[test] #[test]
fn test_root_path() { fn test_root_path() {
assert_eq!(Path::new(b!("a/b/c")).root_path(), None); assert!(Path::new(b!("a/b/c")).root_path() == None);
assert_eq!(Path::new(b!("/a/b/c")).root_path(), Some(Path::new("/"))); assert!(Path::new(b!("/a/b/c")).root_path() == Some(Path::new("/")));
} }
#[test] #[test]
@ -827,7 +827,7 @@ mod tests {
let path = Path::new($path); let path = Path::new($path);
let join = Path::new($join); let join = Path::new($join);
let res = path.join(&join); let res = path.join(&join);
assert_eq!(res.as_str(), Some($exp)); assert!(res.as_str() == Some($exp));
} }
) )
) )
@ -847,14 +847,14 @@ mod tests {
{ {
let path = Path::new($path); let path = Path::new($path);
let res = path.join_many($join); let res = path.join_many($join);
assert_eq!(res.as_str(), Some($exp)); assert!(res.as_str() == Some($exp));
} }
); );
(v: $path:expr, $join:expr, $exp:expr) => ( (v: $path:expr, $join:expr, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let res = path.join_many($join); let res = path.join_many($join);
assert_eq!(res.as_vec(), $exp); assert!(res.as_vec() == $exp);
} }
) )
) )
@ -928,7 +928,7 @@ mod tests {
let mut p1 = Path::new(path); let mut p1 = Path::new(path);
p1.$set(arg); p1.$set(arg);
let p2 = Path::new(path); let p2 = Path::new(path);
assert_eq!(p1, p2.$with(arg)); assert!(p1 == p2.$with(arg));
} }
); );
(v: $path:expr, $set:ident, $with:ident, $arg:expr) => ( (v: $path:expr, $set:ident, $with:ident, $arg:expr) => (
@ -938,7 +938,7 @@ mod tests {
let mut p1 = Path::new(path); let mut p1 = Path::new(path);
p1.$set(arg); p1.$set(arg);
let p2 = Path::new(path); let p2 = Path::new(path);
assert_eq!(p1, p2.$with(arg)); assert!(p1 == p2.$with(arg));
} }
) )
) )
@ -989,10 +989,10 @@ mod tests {
(v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => ( (v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => (
{ {
let path = $path; let path = $path;
assert_eq!(path.filename(), $filename); assert!(path.filename() == $filename);
assert_eq!(path.dirname(), $dirname); assert!(path.dirname() == $dirname);
assert_eq!(path.filestem(), $filestem); assert!(path.filestem() == $filestem);
assert_eq!(path.extension(), $ext); assert!(path.extension() == $ext);
} }
) )
) )

View file

@ -1097,13 +1097,13 @@ mod tests {
(s: $path:expr, $exp:expr) => ( (s: $path:expr, $exp:expr) => (
{ {
let path = $path; let path = $path;
assert_eq!(path.as_str(), Some($exp)); assert!(path.as_str() == Some($exp));
} }
); );
(v: $path:expr, $exp:expr) => ( (v: $path:expr, $exp:expr) => (
{ {
let path = $path; let path = $path;
assert_eq!(path.as_vec(), $exp); assert!(path.as_vec() == $exp);
} }
) )
) )
@ -1270,10 +1270,10 @@ mod tests {
#[test] #[test]
fn test_opt_paths() { fn test_opt_paths() {
assert_eq!(Path::new_opt(b!("foo\\bar", 0)), None); assert!(Path::new_opt(b!("foo\\bar", 0)) == None);
assert_eq!(Path::new_opt(b!("foo\\bar", 0x80)), None); assert!(Path::new_opt(b!("foo\\bar", 0x80)) == None);
t!(v: Path::new_opt(b!("foo\\bar")).unwrap(), b!("foo\\bar")); t!(v: Path::new_opt(b!("foo\\bar")).unwrap(), b!("foo\\bar"));
assert_eq!(Path::new_opt("foo\\bar\0"), None); assert!(Path::new_opt("foo\\bar\0") == None);
t!(s: Path::new_opt("foo\\bar").unwrap(), "foo\\bar"); t!(s: Path::new_opt("foo\\bar").unwrap(), "foo\\bar");
} }
@ -1343,7 +1343,7 @@ mod tests {
{ {
let path = $path; let path = $path;
let path = Path::new(path); let path = Path::new(path);
assert_eq!(path.$op(), Some($exp)); assert!(path.$op() == Some($exp));
} }
); );
(s: $path:expr, $op:ident, $exp:expr, opt) => ( (s: $path:expr, $op:ident, $exp:expr, opt) => (
@ -1351,14 +1351,14 @@ mod tests {
let path = $path; let path = $path;
let path = Path::new(path); let path = Path::new(path);
let left = path.$op(); let left = path.$op();
assert_eq!(left, $exp); assert!(left == $exp);
} }
); );
(v: $path:expr, $op:ident, $exp:expr) => ( (v: $path:expr, $op:ident, $exp:expr) => (
{ {
let path = $path; let path = $path;
let path = Path::new(path); let path = Path::new(path);
assert_eq!(path.$op(), $exp); assert!(path.$op() == $exp);
} }
) )
) )
@ -1469,7 +1469,7 @@ mod tests {
let mut p1 = Path::new(path); let mut p1 = Path::new(path);
let p2 = p1.clone(); let p2 = p1.clone();
p1.push(join); p1.push(join);
assert_eq!(p1, p2.join(join)); assert!(p1 == p2.join(join));
} }
) )
) )
@ -1483,9 +1483,9 @@ mod tests {
// we do want to check one odd case though to ensure the prefix is re-parsed // we do want to check one odd case though to ensure the prefix is re-parsed
let mut p = Path::new("\\\\?\\C:"); let mut p = Path::new("\\\\?\\C:");
assert_eq!(prefix(&p), Some(VerbatimPrefix(2))); assert!(prefix(&p) == Some(VerbatimPrefix(2)));
p.push("foo"); p.push("foo");
assert_eq!(prefix(&p), Some(VerbatimDiskPrefix)); assert!(prefix(&p) == Some(VerbatimDiskPrefix));
assert_eq!(p.as_str(), Some("\\\\?\\C:\\foo")); assert_eq!(p.as_str(), Some("\\\\?\\C:\\foo"));
// and another with verbatim non-normalized paths // and another with verbatim non-normalized paths
@ -1586,7 +1586,7 @@ mod tests {
assert!(p.as_str() == Some(left), assert!(p.as_str() == Some(left),
"`{}`.pop() failed; expected remainder `{}`, found `{}`", "`{}`.pop() failed; expected remainder `{}`, found `{}`",
pstr, left, p.as_str().unwrap()); pstr, left, p.as_str().unwrap());
assert_eq!(result, $right); assert!(result == $right);
} }
); );
(v: [$($path:expr),+], [$($left:expr),+], $right:expr) => ( (v: [$($path:expr),+], [$($left:expr),+], $right:expr) => (
@ -1594,7 +1594,7 @@ mod tests {
let mut p = Path::new(b!($($path),+)); let mut p = Path::new(b!($($path),+));
let result = p.pop(); let result = p.pop();
assert_eq!(p.as_vec(), b!($($left),+)); assert_eq!(p.as_vec(), b!($($left),+));
assert_eq!(result, $right); assert!(result == $right);
} }
) )
) )
@ -1637,16 +1637,16 @@ mod tests {
#[test] #[test]
fn test_root_path() { fn test_root_path() {
assert_eq!(Path::new("a\\b\\c").root_path(), None); assert!(Path::new("a\\b\\c").root_path() == None);
assert_eq!(Path::new("\\a\\b\\c").root_path(), Some(Path::new("\\"))); assert!(Path::new("\\a\\b\\c").root_path() == Some(Path::new("\\")));
assert_eq!(Path::new("C:a").root_path(), Some(Path::new("C:"))); assert!(Path::new("C:a").root_path() == Some(Path::new("C:")));
assert_eq!(Path::new("C:\\a").root_path(), Some(Path::new("C:\\"))); assert!(Path::new("C:\\a").root_path() == Some(Path::new("C:\\")));
assert_eq!(Path::new("\\\\a\\b\\c").root_path(), Some(Path::new("\\\\a\\b"))); assert!(Path::new("\\\\a\\b\\c").root_path() == Some(Path::new("\\\\a\\b")));
assert_eq!(Path::new("\\\\?\\a\\b").root_path(), Some(Path::new("\\\\?\\a"))); assert!(Path::new("\\\\?\\a\\b").root_path() == Some(Path::new("\\\\?\\a")));
assert_eq!(Path::new("\\\\?\\C:\\a").root_path(), Some(Path::new("\\\\?\\C:\\"))); assert!(Path::new("\\\\?\\C:\\a").root_path() == Some(Path::new("\\\\?\\C:\\")));
assert_eq!(Path::new("\\\\?\\UNC\\a\\b\\c").root_path(), assert!(Path::new("\\\\?\\UNC\\a\\b\\c").root_path() ==
Some(Path::new("\\\\?\\UNC\\a\\b"))); Some(Path::new("\\\\?\\UNC\\a\\b")));
assert_eq!(Path::new("\\\\.\\a\\b").root_path(), Some(Path::new("\\\\.\\a"))); assert!(Path::new("\\\\.\\a\\b").root_path() == Some(Path::new("\\\\.\\a")));
} }
#[test] #[test]
@ -1808,7 +1808,7 @@ mod tests {
let mut p1 = Path::new(path); let mut p1 = Path::new(path);
p1.$set(arg); p1.$set(arg);
let p2 = Path::new(path); let p2 = Path::new(path);
assert_eq!(p1, p2.$with(arg)); assert!(p1 == p2.$with(arg));
} }
); );
(v: $path:expr, $set:ident, $with:ident, $arg:expr) => ( (v: $path:expr, $set:ident, $with:ident, $arg:expr) => (
@ -1818,7 +1818,7 @@ mod tests {
let mut p1 = Path::new(path); let mut p1 = Path::new(path);
p1.$set(arg); p1.$set(arg);
let p2 = Path::new(path); let p2 = Path::new(path);
assert_eq!(p1, p2.$with(arg)); assert!(p1 == p2.$with(arg));
} }
) )
) )
@ -1870,10 +1870,10 @@ mod tests {
(v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => ( (v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => (
{ {
let path = $path; let path = $path;
assert_eq!(path.filename(), $filename); assert!(path.filename() == $filename);
assert_eq!(path.dirname(), $dirname); assert!(path.dirname() == $dirname);
assert_eq!(path.filestem(), $filestem); assert!(path.filestem() == $filestem);
assert_eq!(path.extension(), $ext); assert!(path.extension() == $ext);
} }
) )
) )
@ -2325,7 +2325,7 @@ mod tests {
let path = Path::new($path); let path = Path::new($path);
let exp: Option<&str> = $exp; let exp: Option<&str> = $exp;
let exp = exp.map(|s| Path::new(s)); let exp = exp.map(|s| Path::new(s));
assert_eq!(make_non_verbatim(&path), exp); assert!(make_non_verbatim(&path) == exp);
} }
) )
) )

View file

@ -636,6 +636,6 @@ pub mod ptr_tests {
let mut xs = [0u8, ..20]; let mut xs = [0u8, ..20];
let ptr = xs.as_mut_ptr(); let ptr = xs.as_mut_ptr();
unsafe { set_memory(ptr, 5u8, xs.len()); } unsafe { set_memory(ptr, 5u8, xs.len()); }
assert_eq!(xs, [5u8, ..20]); assert!(xs == [5u8, ..20]);
} }
} }

View file

@ -257,7 +257,7 @@ mod tests {
use rand::*; use rand::*;
use super::*; use super::*;
#[deriving(Eq)] #[deriving(Eq, Show)]
struct ConstRand(uint); struct ConstRand(uint);
impl Rand for ConstRand { impl Rand for ConstRand {
fn rand<R: Rng>(_: &mut R) -> ConstRand { fn rand<R: Rng>(_: &mut R) -> ConstRand {

View file

@ -111,7 +111,7 @@ mod test {
let mut rng = ReaderRng::new(MemReader::new(v.to_owned())); let mut rng = ReaderRng::new(MemReader::new(v.to_owned()));
rng.fill_bytes(w); rng.fill_bytes(w);
assert_eq!(v, w); assert!(v == w);
} }
#[test] #[test]

View file

@ -858,7 +858,7 @@ pub struct UTF16Items<'a> {
priv iter: vec::Items<'a, u16> priv iter: vec::Items<'a, u16>
} }
/// The possibilities for values decoded from a `u16` stream. /// The possibilities for values decoded from a `u16` stream.
#[deriving(Eq, TotalEq, Clone)] #[deriving(Eq, TotalEq, Clone, Show)]
pub enum UTF16Item { pub enum UTF16Item {
/// A valid codepoint. /// A valid codepoint.
ScalarValue(char), ScalarValue(char),
@ -3743,7 +3743,7 @@ mod tests {
]; ];
assert_eq!("".as_bytes(), &[]); assert_eq!("".as_bytes(), &[]);
assert_eq!("abc".as_bytes(), &['a' as u8, 'b' as u8, 'c' as u8]); assert_eq!("abc".as_bytes(), &['a' as u8, 'b' as u8, 'c' as u8]);
assert_eq!("ศไทย中华Việt Nam".as_bytes(), v); assert_eq!("ศไทย中华Việt Nam".as_bytes(), v.as_slice());
} }
#[test] #[test]
@ -4442,11 +4442,11 @@ mod tests {
assert!(o.lt(&Slice("bcdef"))); assert!(o.lt(&Slice("bcdef")));
assert_eq!(Owned(~""), Default::default()); assert_eq!(Owned(~""), Default::default());
assert_eq!(s.cmp(&o), Equal); assert!(s.cmp(&o) == Equal);
assert!(s.equals(&o)); assert!(s.equals(&o));
assert!(s.equiv(&o)); assert!(s.equiv(&o));
assert_eq!(o.cmp(&s), Equal); assert!(o.cmp(&s) == Equal);
assert!(o.equals(&s)); assert!(o.equals(&s));
assert!(o.equiv(&s)); assert!(o.equiv(&s));
} }

View file

@ -97,7 +97,7 @@ pub struct Stealer<T> {
} }
/// When stealing some data, this is an enumeration of the possible outcomes. /// When stealing some data, this is an enumeration of the possible outcomes.
#[deriving(Eq)] #[deriving(Eq, Show)]
pub enum Stolen<T> { pub enum Stolen<T> {
/// The deque was empty at the time of stealing /// The deque was empty at the time of stealing
Empty, Empty,

View file

@ -345,10 +345,10 @@ mod tests {
assert!(!big.equals(&small)); assert!(!big.equals(&small));
// TotalOrd // TotalOrd
assert_eq!(small.cmp(&small), Equal); assert!(small.cmp(&small) == Equal);
assert_eq!(big.cmp(&big), Equal); assert!(big.cmp(&big) == Equal);
assert_eq!(small.cmp(&big), Less); assert!(small.cmp(&big) == Less);
assert_eq!(big.cmp(&small), Greater); assert!(big.cmp(&small) == Greater);
} }
#[test] #[test]

View file

@ -2127,7 +2127,7 @@ pub trait MutableVector<'a, T> {
/// ```rust /// ```rust
/// let mut v = ["a", "b", "c", "d"]; /// let mut v = ["a", "b", "c", "d"];
/// v.swap(1, 3); /// v.swap(1, 3);
/// assert_eq!(v, ["a", "d", "c", "b"]); /// assert!(v == ["a", "d", "c", "b"]);
/// ``` /// ```
fn swap(self, a: uint, b: uint); fn swap(self, a: uint, b: uint);
@ -2148,24 +2148,23 @@ pub trait MutableVector<'a, T> {
/// // scoped to restrict the lifetime of the borrows /// // scoped to restrict the lifetime of the borrows
/// { /// {
/// let (left, right) = v.mut_split_at(0); /// let (left, right) = v.mut_split_at(0);
/// assert_eq!(left, &mut []); /// assert!(left == &mut []);
/// assert_eq!(right, &mut [1, 2, 3, 4, 5, 6]); /// assert!(right == &mut [1, 2, 3, 4, 5, 6]);
/// } /// }
/// ///
/// { /// {
/// let (left, right) = v.mut_split_at(2); /// let (left, right) = v.mut_split_at(2);
/// assert_eq!(left, &mut [1, 2]); /// assert!(left == &mut [1, 2]);
/// assert_eq!(right, &mut [3, 4, 5, 6]); /// assert!(right == &mut [3, 4, 5, 6]);
/// } /// }
/// ///
/// { /// {
/// let (left, right) = v.mut_split_at(6); /// let (left, right) = v.mut_split_at(6);
/// assert_eq!(left, &mut [1, 2, 3, 4, 5, 6]); /// assert!(left == &mut [1, 2, 3, 4, 5, 6]);
/// assert_eq!(right, &mut []); /// assert!(right == &mut []);
/// } /// }
/// ``` /// ```
fn mut_split_at(self, mid: uint) -> (&'a mut [T], fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]);
&'a mut [T]);
/// Reverse the order of elements in a vector, in place. /// Reverse the order of elements in a vector, in place.
/// ///
@ -2174,7 +2173,7 @@ pub trait MutableVector<'a, T> {
/// ```rust /// ```rust
/// let mut v = [1, 2, 3]; /// let mut v = [1, 2, 3];
/// v.reverse(); /// v.reverse();
/// assert_eq!(v, [3, 2, 1]); /// assert!(v == [3, 2, 1]);
/// ``` /// ```
fn reverse(self); fn reverse(self);
@ -2189,11 +2188,11 @@ pub trait MutableVector<'a, T> {
/// ```rust /// ```rust
/// let mut v = [5i, 4, 1, 3, 2]; /// let mut v = [5i, 4, 1, 3, 2];
/// v.sort_by(|a, b| a.cmp(b)); /// v.sort_by(|a, b| a.cmp(b));
/// assert_eq!(v, [1, 2, 3, 4, 5]); /// assert!(v == [1, 2, 3, 4, 5]);
/// ///
/// // reverse sorting /// // reverse sorting
/// v.sort_by(|a, b| b.cmp(a)); /// v.sort_by(|a, b| b.cmp(a));
/// assert_eq!(v, [5, 4, 3, 2, 1]); /// assert!(v == [5, 4, 3, 2, 1]);
/// ``` /// ```
fn sort_by(self, compare: |&T, &T| -> Ordering); fn sort_by(self, compare: |&T, &T| -> Ordering);
@ -2434,12 +2433,12 @@ pub trait MutableCloneableVector<T> {
/// let mut dst = [0, 0, 0]; /// let mut dst = [0, 0, 0];
/// let src = [1, 2]; /// let src = [1, 2];
/// ///
/// assert_eq!(dst.copy_from(src), 2); /// assert!(dst.copy_from(src) == 2);
/// assert_eq!(dst, [1, 2, 0]); /// assert!(dst == [1, 2, 0]);
/// ///
/// let src2 = [3, 4, 5, 6]; /// let src2 = [3, 4, 5, 6];
/// assert_eq!(dst.copy_from(src2), 3); /// assert!(dst.copy_from(src2) == 3);
/// assert_eq!(dst, [3, 4, 5]); /// assert!(dst == [3, 4, 5]);
/// ``` /// ```
fn copy_from(self, &[T]) -> uint; fn copy_from(self, &[T]) -> uint;
} }
@ -2467,7 +2466,7 @@ pub trait MutableTotalOrdVector<T> {
/// let mut v = [-5, 4, 1, -3, 2]; /// let mut v = [-5, 4, 1, -3, 2];
/// ///
/// v.sort(); /// v.sort();
/// assert_eq!(v, [-5, -3, 1, 2, 4]); /// assert!(v == [-5, -3, 1, 2, 4]);
/// ``` /// ```
fn sort(self); fn sort(self);
} }
@ -3391,12 +3390,12 @@ mod tests {
for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() { for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() {
v.swap(a, b); v.swap(a, b);
match i { match i {
0 => assert_eq!(v, [1, 3, 2]), 0 => assert!(v == [1, 3, 2]),
1 => assert_eq!(v, [3, 1, 2]), 1 => assert!(v == [3, 1, 2]),
2 => assert_eq!(v, [3, 2, 1]), 2 => assert!(v == [3, 2, 1]),
3 => assert_eq!(v, [2, 3, 1]), 3 => assert!(v == [2, 3, 1]),
4 => assert_eq!(v, [2, 1, 3]), 4 => assert!(v == [2, 1, 3]),
5 => assert_eq!(v, [1, 2, 3]), 5 => assert!(v == [1, 2, 3]),
_ => fail!(), _ => fail!(),
} }
} }
@ -3530,7 +3529,7 @@ mod tests {
let mut v = [0xDEADBEEFu]; let mut v = [0xDEADBEEFu];
v.sort(); v.sort();
assert_eq!(v, [0xDEADBEEF]); assert!(v == [0xDEADBEEF]);
} }
#[test] #[test]
@ -3896,7 +3895,7 @@ mod tests {
for x in xs.mut_iter() { for x in xs.mut_iter() {
*x += 1; *x += 1;
} }
assert_eq!(xs, [2, 3, 4, 5, 6]) assert!(xs == [2, 3, 4, 5, 6])
} }
#[test] #[test]
@ -3920,7 +3919,7 @@ mod tests {
for (i,x) in xs.mut_rev_iter().enumerate() { for (i,x) in xs.mut_rev_iter().enumerate() {
*x += i; *x += i;
} }
assert_eq!(xs, [5, 5, 5, 5, 5]) assert!(xs == [5, 5, 5, 5, 5])
} }
#[test] #[test]
@ -4048,19 +4047,19 @@ mod tests {
let mut a = [1,2,3,4,5]; let mut a = [1,2,3,4,5];
let b = ~[6,7,8]; let b = ~[6,7,8];
assert_eq!(a.move_from(b, 0, 3), 3); assert_eq!(a.move_from(b, 0, 3), 3);
assert_eq!(a, [6,7,8,4,5]); assert!(a == [6,7,8,4,5]);
let mut a = [7,2,8,1]; let mut a = [7,2,8,1];
let b = ~[3,1,4,1,5,9]; let b = ~[3,1,4,1,5,9];
assert_eq!(a.move_from(b, 0, 6), 4); assert_eq!(a.move_from(b, 0, 6), 4);
assert_eq!(a, [3,1,4,1]); assert!(a == [3,1,4,1]);
let mut a = [1,2,3,4]; let mut a = [1,2,3,4];
let b = ~[5,6,7,8,9,0]; let b = ~[5,6,7,8,9,0];
assert_eq!(a.move_from(b, 2, 3), 1); assert_eq!(a.move_from(b, 2, 3), 1);
assert_eq!(a, [7,2,3,4]); assert!(a == [7,2,3,4]);
let mut a = [1,2,3,4,5]; let mut a = [1,2,3,4,5];
let b = ~[5,6,7,8,9,0]; let b = ~[5,6,7,8,9,0];
assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2); assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2);
assert_eq!(a, [1,2,6,7,5]); assert!(a == [1,2,6,7,5]);
} }
#[test] #[test]
@ -4068,18 +4067,18 @@ mod tests {
let mut a = [1,2,3,4,5]; let mut a = [1,2,3,4,5];
let b = [6,7,8]; let b = [6,7,8];
assert_eq!(a.copy_from(b), 3); assert_eq!(a.copy_from(b), 3);
assert_eq!(a, [6,7,8,4,5]); assert!(a == [6,7,8,4,5]);
let mut c = [7,2,8,1]; let mut c = [7,2,8,1];
let d = [3,1,4,1,5,9]; let d = [3,1,4,1,5,9];
assert_eq!(c.copy_from(d), 4); assert_eq!(c.copy_from(d), 4);
assert_eq!(c, [3,1,4,1]); assert!(c == [3,1,4,1]);
} }
#[test] #[test]
fn test_reverse_part() { fn test_reverse_part() {
let mut values = [1,2,3,4,5]; let mut values = [1,2,3,4,5];
values.mut_slice(1, 4).reverse(); values.mut_slice(1, 4).reverse();
assert_eq!(values, [1,4,3,2,5]); assert!(values == [1,4,3,2,5]);
} }
#[test] #[test]
@ -4117,9 +4116,9 @@ mod tests {
use vec::bytes::MutableByteVector; use vec::bytes::MutableByteVector;
let mut values = [1u8,2,3,4,5]; let mut values = [1u8,2,3,4,5];
values.mut_slice(0,5).set_memory(0xAB); values.mut_slice(0,5).set_memory(0xAB);
assert_eq!(values, [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
values.mut_slice(2,4).set_memory(0xFF); values.mut_slice(2,4).set_memory(0xFF);
assert_eq!(values, [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]);
} }
#[test] #[test]
@ -4145,18 +4144,18 @@ mod tests {
let mut values = [1u8,2,3,4,5]; let mut values = [1u8,2,3,4,5];
{ {
let (left, right) = values.mut_split_at(2); let (left, right) = values.mut_split_at(2);
assert_eq!(left.slice(0, left.len()), [1, 2]); assert!(left.slice(0, left.len()) == [1, 2]);
for p in left.mut_iter() { for p in left.mut_iter() {
*p += 1; *p += 1;
} }
assert_eq!(right.slice(0, right.len()), [3, 4, 5]); assert!(right.slice(0, right.len()) == [3, 4, 5]);
for p in right.mut_iter() { for p in right.mut_iter() {
*p += 2; *p += 2;
} }
} }
assert_eq!(values, [2, 3, 5, 6, 7]); assert!(values == [2, 3, 5, 6, 7]);
} }
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
@ -4280,13 +4279,13 @@ mod tests {
for slice in xs.mut_split(|x| *x == 0) { for slice in xs.mut_split(|x| *x == 0) {
slice.reverse(); slice.reverse();
} }
assert_eq!(xs, [0,1,0,3,2,0,0,5,4,0]); assert!(xs == [0,1,0,3,2,0,0,5,4,0]);
let mut xs = [0,1,0,2,3,0,0,4,5,0,6,7]; let mut xs = [0,1,0,2,3,0,0,4,5,0,6,7];
for slice in xs.mut_split(|x| *x == 0).take(5) { for slice in xs.mut_split(|x| *x == 0).take(5) {
slice.reverse(); slice.reverse();
} }
assert_eq!(xs, [0,1,0,3,2,0,0,5,4,0,6,7]); assert!(xs == [0,1,0,3,2,0,0,5,4,0,6,7]);
} }
#[test] #[test]
@ -4295,7 +4294,7 @@ mod tests {
for slice in xs.mut_split(|x| *x == 0).rev().take(4) { for slice in xs.mut_split(|x| *x == 0).rev().take(4) {
slice.reverse(); slice.reverse();
} }
assert_eq!(xs, [1,2,0,4,3,0,0,6,5,0]); assert!(xs == [1,2,0,4,3,0,0,6,5,0]);
} }
#[test] #[test]
@ -4307,7 +4306,7 @@ mod tests {
} }
} }
let result = [0u8, 0, 0, 1, 1, 1, 2]; let result = [0u8, 0, 0, 1, 1, 1, 2];
assert_eq!(v, result); assert!(v == result);
} }
#[test] #[test]
@ -4319,7 +4318,7 @@ mod tests {
} }
} }
let result = [2u8, 2, 2, 1, 1, 1, 0]; let result = [2u8, 2, 2, 1, 1, 1, 0];
assert_eq!(v, result); assert!(v == result);
} }
#[test] #[test]

View file

@ -94,7 +94,7 @@ pub struct Mutex {
priv lock: StaticMutex, priv lock: StaticMutex,
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
enum Flavor { enum Flavor {
Unlocked, Unlocked,
TryLockAcquisition, TryLockAcquisition,

View file

@ -979,7 +979,7 @@ mod test {
// because of the SCTable, I now need a tidy way of // because of the SCTable, I now need a tidy way of
// creating syntax objects. Sigh. // creating syntax objects. Sigh.
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
enum TestSC { enum TestSC {
M(Mrk), M(Mrk),
R(Ident,Name) R(Ident,Name)
@ -1024,9 +1024,9 @@ mod test {
assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4); assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4);
{ {
let table = t.table.borrow(); let table = t.table.borrow();
assert_eq!(table.get()[2],Mark(9,0)); assert!(table.get()[2] == Mark(9,0));
assert_eq!(table.get()[3],Rename(id(101,0),14,2)); assert!(table.get()[3] == Rename(id(101,0),14,2));
assert_eq!(table.get()[4],Mark(3,3)); assert!(table.get()[4] == Mark(3,3));
} }
assert_eq!(refold_test_sc(4,&t),test_sc); assert_eq!(refold_test_sc(4,&t),test_sc);
} }
@ -1045,8 +1045,8 @@ mod test {
assert_eq!(unfold_marks(~[3,7],EMPTY_CTXT,&mut t),3); assert_eq!(unfold_marks(~[3,7],EMPTY_CTXT,&mut t),3);
{ {
let table = t.table.borrow(); let table = t.table.borrow();
assert_eq!(table.get()[2],Mark(7,0)); assert!(table.get()[2] == Mark(7,0));
assert_eq!(table.get()[3],Mark(3,2)); assert!(table.get()[3] == Mark(3,2));
} }
} }

View file

@ -455,7 +455,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
} }
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
pub enum ReprAttr { pub enum ReprAttr {
ReprAny, ReprAny,
ReprInt(Span, IntType), ReprInt(Span, IntType),
@ -472,7 +472,7 @@ impl ReprAttr {
} }
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
pub enum IntType { pub enum IntType {
SignedInt(ast::IntTy), SignedInt(ast::IntTy),
UnsignedInt(ast::UintTy) UnsignedInt(ast::UintTy)

View file

@ -32,13 +32,13 @@ pub trait Pos {
/// A byte offset. Keep this small (currently 32-bits), as AST contains /// A byte offset. Keep this small (currently 32-bits), as AST contains
/// a lot of them. /// a lot of them.
#[deriving(Clone, Eq, Hash, Ord)] #[deriving(Clone, Eq, Hash, Ord, Show)]
pub struct BytePos(u32); pub struct BytePos(u32);
/// A character offset. Because of multibyte utf8 characters, a byte offset /// A character offset. Because of multibyte utf8 characters, a byte offset
/// is not equivalent to a character offset. The CodeMap will convert BytePos /// is not equivalent to a character offset. The CodeMap will convert BytePos
/// values to CharPos values as necessary. /// values to CharPos values as necessary.
#[deriving(Eq, Hash, Ord)] #[deriving(Eq, Hash, Ord, Show)]
pub struct CharPos(uint); pub struct CharPos(uint);
// FIXME: Lots of boilerplate in these impls, but so far my attempts to fix // FIXME: Lots of boilerplate in these impls, but so far my attempts to fix
@ -84,7 +84,7 @@ are *absolute* positions from the beginning of the codemap, not positions
relative to FileMaps. Methods on the CodeMap can be used to relate spans back relative to FileMaps. Methods on the CodeMap can be used to relate spans back
to the original source. to the original source.
*/ */
#[deriving(Clone, Hash)] #[deriving(Clone, Show, Hash)]
pub struct Span { pub struct Span {
lo: BytePos, lo: BytePos,
hi: BytePos, hi: BytePos,
@ -160,7 +160,7 @@ pub struct LocWithOpt {
pub struct FileMapAndLine {fm: @FileMap, line: uint} pub struct FileMapAndLine {fm: @FileMap, line: uint}
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos} pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
#[deriving(Clone, Hash)] #[deriving(Clone, Hash, Show)]
pub enum MacroFormat { pub enum MacroFormat {
// e.g. #[deriving(...)] <item> // e.g. #[deriving(...)] <item>
MacroAttribute, MacroAttribute,
@ -168,7 +168,7 @@ pub enum MacroFormat {
MacroBang MacroBang
} }
#[deriving(Clone, Hash)] #[deriving(Clone, Hash, Show)]
pub struct NameAndSpan { pub struct NameAndSpan {
name: ~str, name: ~str,
// the format with which the macro was invoked. // the format with which the macro was invoked.
@ -177,7 +177,7 @@ pub struct NameAndSpan {
} }
/// Extra information for tracking macro expansion of spans /// Extra information for tracking macro expansion of spans
#[deriving(Hash)] #[deriving(Hash, Show)]
pub struct ExpnInfo { pub struct ExpnInfo {
call_site: Span, call_site: Span,
callee: NameAndSpan callee: NameAndSpan

View file

@ -32,7 +32,7 @@ pub trait Reader {
fn dup(&self) -> ~Reader:; fn dup(&self) -> ~Reader:;
} }
#[deriving(Clone, Eq)] #[deriving(Clone, Eq, Show)]
pub struct TokenAndSpan { pub struct TokenAndSpan {
tok: token::Token, tok: token::Token,
sp: Span, sp: Span,

View file

@ -312,7 +312,7 @@ mod test {
} }
#[test] fn path_exprs_1() { #[test] fn path_exprs_1() {
assert_eq!(string_to_expr(~"a"), assert!(string_to_expr(~"a") ==
@ast::Expr{ @ast::Expr{
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::ExprPath(ast::Path { node: ast::ExprPath(ast::Path {
@ -331,7 +331,7 @@ mod test {
} }
#[test] fn path_exprs_2 () { #[test] fn path_exprs_2 () {
assert_eq!(string_to_expr(~"::a::b"), assert!(string_to_expr(~"::a::b") ==
@ast::Expr { @ast::Expr {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::ExprPath(ast::Path { node: ast::ExprPath(ast::Path {
@ -542,7 +542,7 @@ mod test {
} }
#[test] fn ret_expr() { #[test] fn ret_expr() {
assert_eq!(string_to_expr(~"return d"), assert!(string_to_expr(~"return d") ==
@ast::Expr{ @ast::Expr{
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node:ast::ExprRet(Some(@ast::Expr{ node:ast::ExprRet(Some(@ast::Expr{
@ -565,7 +565,7 @@ mod test {
} }
#[test] fn parse_stmt_1 () { #[test] fn parse_stmt_1 () {
assert_eq!(string_to_stmt(~"b;"), assert!(string_to_stmt(~"b;") ==
@Spanned{ @Spanned{
node: ast::StmtExpr(@ast::Expr { node: ast::StmtExpr(@ast::Expr {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
@ -592,7 +592,7 @@ mod test {
#[test] fn parse_ident_pat () { #[test] fn parse_ident_pat () {
let mut parser = string_to_parser(~"b"); let mut parser = string_to_parser(~"b");
assert_eq!(parser.parse_pat(), assert!(parser.parse_pat() ==
@ast::Pat{id: ast::DUMMY_NODE_ID, @ast::Pat{id: ast::DUMMY_NODE_ID,
node: ast::PatIdent( node: ast::PatIdent(
ast::BindByValue(ast::MutImmutable), ast::BindByValue(ast::MutImmutable),
@ -615,7 +615,7 @@ mod test {
// check the contents of the tt manually: // check the contents of the tt manually:
#[test] fn parse_fundecl () { #[test] fn parse_fundecl () {
// this test depends on the intern order of "fn" and "int" // this test depends on the intern order of "fn" and "int"
assert_eq!(string_to_item(~"fn a (b : int) { b; }"), assert!(string_to_item(~"fn a (b : int) { b; }") ==
Some( Some(
@ast::Item{ident:str_to_ident("a"), @ast::Item{ident:str_to_ident("a"),
attrs:~[], attrs:~[],

View file

@ -23,7 +23,7 @@ use std::local_data;
use std::path::BytesContainer; use std::path::BytesContainer;
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[deriving(Clone, Encodable, Decodable, Eq, Hash)] #[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
pub enum BinOp { pub enum BinOp {
PLUS, PLUS,
MINUS, MINUS,
@ -38,7 +38,7 @@ pub enum BinOp {
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[deriving(Clone, Encodable, Decodable, Eq, Hash)] #[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
pub enum Token { pub enum Token {
/* Expression-operator symbols. */ /* Expression-operator symbols. */
EQ, EQ,
@ -118,6 +118,24 @@ pub enum Nonterminal {
NtMatchers(~[ast::Matcher]) NtMatchers(~[ast::Matcher])
} }
impl fmt::Show for Nonterminal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
NtItem(..) => f.pad("NtItem(..)"),
NtBlock(..) => f.pad("NtBlock(..)"),
NtStmt(..) => f.pad("NtStmt(..)"),
NtPat(..) => f.pad("NtPat(..)"),
NtExpr(..) => f.pad("NtExpr(..)"),
NtTy(..) => f.pad("NtTy(..)"),
NtIdent(..) => f.pad("NtIdent(..)"),
NtAttr(..) => f.pad("NtAttr(..)"),
NtPath(..) => f.pad("NtPath(..)"),
NtTT(..) => f.pad("NtTT(..)"),
NtMatchers(..) => f.pad("NtMatchers(..)"),
}
}
}
pub fn binop_to_str(o: BinOp) -> ~str { pub fn binop_to_str(o: BinOp) -> ~str {
match o { match o {
PLUS => ~"+", PLUS => ~"+",

View file

@ -18,6 +18,7 @@ use collections::HashMap;
use std::cast; use std::cast;
use std::cell::RefCell; use std::cell::RefCell;
use std::cmp::Equiv; use std::cmp::Equiv;
use std::fmt;
use std::hash::Hash; use std::hash::Hash;
use std::rc::Rc; use std::rc::Rc;
@ -114,6 +115,13 @@ impl Str for RcStr {
} }
} }
impl fmt::Show for RcStr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use std::fmt::Show;
self.as_slice().fmt(f)
}
}
impl RcStr { impl RcStr {
pub fn new(string: &str) -> RcStr { pub fn new(string: &str) -> RcStr {
RcStr { RcStr {

View file

@ -163,7 +163,7 @@ pub struct TestDescAndFn {
testfn: TestFn, testfn: TestFn,
} }
#[deriving(Clone, Encodable, Decodable, Eq)] #[deriving(Clone, Encodable, Decodable, Eq, Show)]
pub struct Metric { pub struct Metric {
priv value: f64, priv value: f64,
priv noise: f64 priv noise: f64
@ -186,7 +186,7 @@ impl Clone for MetricMap {
} }
/// Analysis of a single change in metric /// Analysis of a single change in metric
#[deriving(Eq)] #[deriving(Eq, Show)]
pub enum MetricChange { pub enum MetricChange {
LikelyNoise, LikelyNoise,
MetricAdded, MetricAdded,
@ -1341,7 +1341,7 @@ mod tests {
let (p, ch) = Chan::new(); let (p, ch) = Chan::new();
run_test(false, desc, ch); run_test(false, desc, ch);
let (_, res, _) = p.recv(); let (_, res, _) = p.recv();
assert_eq!(res, TrIgnored); assert!(res == TrIgnored);
} }
#[test] #[test]
@ -1358,7 +1358,7 @@ mod tests {
let (p, ch) = Chan::new(); let (p, ch) = Chan::new();
run_test(false, desc, ch); run_test(false, desc, ch);
let (_, res, _) = p.recv(); let (_, res, _) = p.recv();
assert_eq!(res, TrOk); assert!(res == TrOk);
} }
#[test] #[test]
@ -1375,7 +1375,7 @@ mod tests {
let (p, ch) = Chan::new(); let (p, ch) = Chan::new();
run_test(false, desc, ch); run_test(false, desc, ch);
let (_, res, _) = p.recv(); let (_, res, _) = p.recv();
assert_eq!(res, TrFailed); assert!(res == TrFailed);
} }
#[test] #[test]

View file

@ -64,7 +64,7 @@ mod imp {
/// A record specifying a time value in seconds and nanoseconds. /// A record specifying a time value in seconds and nanoseconds.
#[deriving(Clone, DeepClone, Eq, Encodable, Decodable)] #[deriving(Clone, DeepClone, Eq, Encodable, Decodable, Show)]
pub struct Timespec { sec: i64, nsec: i32 } pub struct Timespec { sec: i64, nsec: i32 }
/* /*
* Timespec assumes that pre-epoch Timespecs have negative sec and positive * Timespec assumes that pre-epoch Timespecs have negative sec and positive
@ -191,7 +191,7 @@ pub fn tzset() {
} }
} }
#[deriving(Clone, DeepClone, Eq, Encodable, Decodable)] #[deriving(Clone, DeepClone, Eq, Encodable, Decodable, Show)]
pub struct Tm { pub struct Tm {
tm_sec: i32, // seconds after the minute ~[0-60] tm_sec: i32, // seconds after the minute ~[0-60]
tm_min: i32, // minutes after the hour ~[0-59] tm_min: i32, // minutes after the hour ~[0-59]
@ -1138,7 +1138,7 @@ mod tests {
let time = Timespec::new(1234567890, 54321); let time = Timespec::new(1234567890, 54321);
let local = at(time); let local = at(time);
error!("time_at: {:?}", local); debug!("time_at: {:?}", local);
assert_eq!(local.tm_sec, 30_i32); assert_eq!(local.tm_sec, 30_i32);
assert_eq!(local.tm_min, 31_i32); assert_eq!(local.tm_min, 31_i32);
@ -1355,7 +1355,7 @@ mod tests {
let utc = at_utc(time); let utc = at_utc(time);
let local = at(time); let local = at(time);
error!("test_ctime: {:?} {:?}", utc.ctime(), local.ctime()); debug!("test_ctime: {:?} {:?}", utc.ctime(), local.ctime());
assert_eq!(utc.ctime(), ~"Fri Feb 13 23:31:30 2009"); assert_eq!(utc.ctime(), ~"Fri Feb 13 23:31:30 2009");
assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009"); assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009");

View file

@ -13,6 +13,7 @@ use std::cmp::Eq;
pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + Eq { pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + Eq {
} }
#[deriving(Show)]
pub struct MyInt { pub struct MyInt {
val: int val: int
} }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Point { x : int } struct Point { x : int }
pub fn main() { pub fn main() {

View file

@ -63,7 +63,7 @@ fn test_ptr() {
} }
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
struct p { struct p {
x: int, x: int,
y: int, y: int,

View file

@ -12,6 +12,7 @@
use std::cmp; use std::cmp;
#[deriving(Show)]
enum cat_type { tuxedo, tabby, tortoiseshell } enum cat_type { tuxedo, tabby, tortoiseshell }
impl cmp::Eq for cat_type { impl cmp::Eq for cat_type {

View file

@ -12,10 +12,10 @@ fn id<T>(x: T) -> T {
x x
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo<T>(T); struct Foo<T>(T);
#[deriving(Eq)] #[deriving(Eq, Show)]
enum Bar<T> { enum Bar<T> {
Bar(T) Bar(T)
} }

View file

@ -16,5 +16,5 @@ use cci_const::bar;
static foo: extern "C" fn() = bar; static foo: extern "C" fn() = bar;
pub fn main() { pub fn main() {
assert_eq!(foo, bar); assert!(foo == bar);
} }

View file

@ -18,6 +18,6 @@ struct S {
} }
pub fn main() { pub fn main() {
assert_eq!(foopy, f); assert!(foopy == f);
assert_eq!(f, s.f); assert!(f == s.f);
} }

View file

@ -10,6 +10,7 @@
use std::cmp; use std::cmp;
#[deriving(Show)]
struct foo { a: int, b: int, c: int } struct foo { a: int, b: int, c: int }
impl cmp::Eq for foo { impl cmp::Eq for foo {

View file

@ -11,7 +11,7 @@
use std::num::FromPrimitive; use std::num::FromPrimitive;
use std::int; use std::int;
#[deriving(Eq, FromPrimitive)] #[deriving(Eq, FromPrimitive, Show)]
enum A { enum A {
Foo = int::MAX, Foo = int::MAX,
Bar = 1, Bar = 1,

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
enum Foo { enum Foo {
Bar, Bar,
Baz, Baz,

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
enum Foo { enum Foo {
Bar(int, int), Bar(int, int),
Baz(f64, f64) Baz(f64, f64)

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo; struct Foo;
pub fn main() { pub fn main() {

View file

@ -10,7 +10,7 @@
#[feature(struct_variant)]; #[feature(struct_variant)];
#[deriving(Eq)] #[deriving(Eq, Show)]
enum S { enum S {
X { x: int, y: int }, X { x: int, y: int },
Y Y

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo(int, int, ~str); struct Foo(int, int, ~str);
pub fn main() { pub fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo { struct Foo {
x: int, x: int,
y: int, y: int,

View file

@ -10,7 +10,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq, Hash)] #[deriving(Eq, Hash, Show)]
struct Foo<T> { struct Foo<T> {
x: int, x: int,
y: T, y: T,

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Show)]
enum chan { chan_t, } enum chan { chan_t, }
impl Eq for chan { impl Eq for chan {

View file

@ -21,6 +21,7 @@ fn test_rec() {
assert_eq!(rs.i, 100); assert_eq!(rs.i, 100);
} }
#[deriving(Show)]
enum mood { happy, sad, } enum mood { happy, sad, }
impl Eq for mood { impl Eq for mood {

View file

@ -20,6 +20,7 @@ fn test_rec() {
assert_eq!(rs.i, 100); assert_eq!(rs.i, 100);
} }
#[deriving(Show)]
enum mood { happy, sad, } enum mood { happy, sad, }
impl Eq for mood { impl Eq for mood {

View file

@ -20,13 +20,13 @@ extern fn uintvoidret(_x: uint) {}
extern fn uintuintuintuintret(x: uint, y: uint, z: uint) -> uint { x+y+z } extern fn uintuintuintuintret(x: uint, y: uint, z: uint) -> uint { x+y+z }
pub fn main() { pub fn main() {
assert_eq!(voidret1, voidret1); assert!(voidret1 == voidret1);
assert!(voidret1 != voidret2); assert!(voidret1 != voidret2);
assert_eq!(uintret, uintret); assert!(uintret == uintret);
assert_eq!(uintvoidret, uintvoidret); assert!(uintvoidret == uintvoidret);
assert_eq!(uintuintuintuintret, uintuintuintuintret); assert!(uintuintuintuintret == uintuintuintuintret);
} }

View file

@ -11,7 +11,7 @@
// Test a foreign function that accepts and returns a struct // Test a foreign function that accepts and returns a struct
// by value. // by value.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct TwoU32s { struct TwoU32s {
one: u32, two: u32 one: u32, two: u32
} }

View file

@ -13,7 +13,7 @@
// ignore-win32 #9205 // ignore-win32 #9205
#[deriving(Eq)] #[deriving(Eq, Show)]
struct TwoU64s { struct TwoU64s {
one: u64, two: u64 one: u64, two: u64
} }

View file

@ -19,6 +19,6 @@ pub fn main() {
let b: extern "C" fn() = f; let b: extern "C" fn() = f;
let c: extern "C" fn() = g; let c: extern "C" fn() = g;
assert_eq!(a, b); assert!(a == b);
assert!(a != c); assert!(a != c);
} }

View file

@ -50,10 +50,10 @@ fn default_foo(x: Foo) {
assert_eq!(x.baz(), (1, 'a')); assert_eq!(x.baz(), (1, 'a'));
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
struct BazHelper<T>(T); struct BazHelper<T>(T);
#[deriving(Eq)] #[deriving(Eq, Show)]
// Ensure that we can use previous type parameters in defaults. // Ensure that we can use previous type parameters in defaults.
struct Baz<T, U = BazHelper<T>, V = Option<U>>(T, U, V); struct Baz<T, U = BazHelper<T>, V = Option<U>>(T, U, V);

View file

@ -11,6 +11,8 @@
// ignore-fast check-fast doesn't like 'extern crate extra' // ignore-fast check-fast doesn't like 'extern crate extra'
// ignore-win32 TempDir may cause IoError on windows: #10462 // ignore-win32 TempDir may cause IoError on windows: #10462
#[feature(macro_rules)];
extern crate extra; extern crate extra;
extern crate glob; extern crate glob;
@ -20,6 +22,12 @@ use std::unstable::finally::Finally;
use std::{os, unstable}; use std::{os, unstable};
use std::io; use std::io;
macro_rules! assert_eq ( ($e1:expr, $e2:expr) => (
if $e1 != $e2 {
fail!("{} != {}", stringify!($e1), stringify!($e2))
}
) )
pub fn main() { pub fn main() {
fn mk_file(path: &str, directory: bool) { fn mk_file(path: &str, directory: bool) {
if directory { if directory {

View file

@ -26,7 +26,7 @@ pub mod pipes {
payload: Option<T> payload: Option<T>
} }
#[deriving(Eq)] #[deriving(Eq, Show)]
#[repr(int)] #[repr(int)]
pub enum state { pub enum state {
empty, empty,

View file

@ -20,9 +20,9 @@
struct S<T> { i:u8, t:T } struct S<T> { i:u8, t:T }
impl<T> S<T> { fn unwrap(self) -> T { self.t } } impl<T> S<T> { fn unwrap(self) -> T { self.t } }
#[deriving(Eq)] #[deriving(Eq, Show)]
struct A((u32, u32)); struct A((u32, u32));
#[deriving(Eq)] #[deriving(Eq, Show)]
struct B(u64); struct B(u64);
pub fn main() { pub fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo(uint); struct Foo(uint);
fn foo() -> Foo { fn foo() -> Foo {

View file

@ -13,6 +13,7 @@
use std::cmp; use std::cmp;
use std::ops; use std::ops;
#[deriving(Show)]
struct Point { struct Point {
x: int, x: int,
y: int y: int

View file

@ -22,7 +22,7 @@ pub fn main() {
let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 };
let transd : [u8, .. 9] = cast::transmute(s); let transd : [u8, .. 9] = cast::transmute(s);
// Don't worry about endianness, the numbers are palindromic. // Don't worry about endianness, the numbers are palindromic.
assert_eq!(transd, assert!(transd ==
[0xff, 0xff, 0xff, 0xff, [0xff, 0xff, 0xff, 0xff,
1, 1,
0xaa, 0xaa, 0xaa, 0xaa]); 0xaa, 0xaa, 0xaa, 0xaa]);
@ -31,7 +31,7 @@ pub fn main() {
let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16}; let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16};
let transd : [u8, .. 4] = cast::transmute(s); let transd : [u8, .. 4] = cast::transmute(s);
// Again, no endianness problems. // Again, no endianness problems.
assert_eq!(transd, assert!(transd ==
[1, 2, 0b10000001, 0b10000001]); [1, 2, 0b10000001, 0b10000001]);
} }
} }

View file

@ -26,11 +26,11 @@ pub fn main() {
unsafe { unsafe {
let s4 = S4 { a: 1, b: [2,3,4] }; let s4 = S4 { a: 1, b: [2,3,4] };
let transd : [u8, .. 4] = cast::transmute(s4); let transd : [u8, .. 4] = cast::transmute(s4);
assert_eq!(transd, [1, 2, 3, 4]); assert!(transd == [1, 2, 3, 4]);
let s5 = S5 { a: 1, b: 0xff_00_00_ff }; let s5 = S5 { a: 1, b: 0xff_00_00_ff };
let transd : [u8, .. 5] = cast::transmute(s5); let transd : [u8, .. 5] = cast::transmute(s5);
// Don't worry about endianness, the u32 is palindromic. // Don't worry about endianness, the u32 is palindromic.
assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); assert!(transd == [1, 0xff, 0, 0, 0xff]);
} }
} }

View file

@ -13,7 +13,7 @@
use std::mem; use std::mem;
#[packed] #[packed]
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo { struct Foo {
bar: u8, bar: u8,
baz: u64 baz: u64

View file

@ -20,11 +20,11 @@ pub fn main() {
unsafe { unsafe {
let s4 = S4(1, [2,3,4]); let s4 = S4(1, [2,3,4]);
let transd : [u8, .. 4] = cast::transmute(s4); let transd : [u8, .. 4] = cast::transmute(s4);
assert_eq!(transd, [1, 2, 3, 4]); assert!(transd == [1, 2, 3, 4]);
let s5 = S5(1, 0xff_00_00_ff); let s5 = S5(1, 0xff_00_00_ff);
let transd : [u8, .. 5] = cast::transmute(s5); let transd : [u8, .. 5] = cast::transmute(s5);
// Don't worry about endianness, the u32 is palindromic. // Don't worry about endianness, the u32 is palindromic.
assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); assert!(transd == [1, 0xff, 0, 0, 0xff]);
} }
} }

View file

@ -27,6 +27,7 @@ use std::mem;
type Type<'tcx> = &'tcx TypeStructure<'tcx>; type Type<'tcx> = &'tcx TypeStructure<'tcx>;
#[deriving(Show)]
enum TypeStructure<'tcx> { enum TypeStructure<'tcx> {
TypeInt, TypeInt,
TypeFunction(Type<'tcx>, Type<'tcx>), TypeFunction(Type<'tcx>, Type<'tcx>),

View file

@ -12,5 +12,5 @@ static FOO: [int, ..4] = [32, ..4];
static BAR: [int, ..4] = [32, 32, 32, 32]; static BAR: [int, ..4] = [32, 32, 32, 32];
pub fn main() { pub fn main() {
assert_eq!(FOO, BAR); assert!(FOO == BAR);
} }

View file

@ -12,7 +12,7 @@
use std::mem::size_of; use std::mem::size_of;
#[deriving(Eq)] #[deriving(Eq, Show)]
enum Either<T, U> { Left(T), Right(U) } enum Either<T, U> { Left(T), Right(U) }
macro_rules! check { macro_rules! check {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq,Clone)] #[deriving(Show,Eq,Clone)]
struct Foo<T> { struct Foo<T> {
bar: T, bar: T,
baz: T baz: T

View file

@ -10,6 +10,7 @@
#[deriving(Show)]
enum foo { large, small, } enum foo { large, small, }
impl Eq for foo { impl Eq for foo {

View file

@ -45,6 +45,7 @@ fn test_str() {
assert_eq!(s1[3], 't' as u8); assert_eq!(s1[3], 't' as u8);
} }
#[deriving(Show)]
enum t { enum t {
tag1, tag1,
tag2(int), tag2(int),

View file

@ -12,6 +12,7 @@ use std::cmp::Eq;
trait MyNum : Eq { } trait MyNum : Eq { }
#[deriving(Show)]
struct MyInt { val: int } struct MyInt { val: int }
impl Eq for MyInt { impl Eq for MyInt {

View file

@ -12,6 +12,7 @@ use std::cmp::Eq;
trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + Eq { } trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + Eq { }
#[deriving(Show)]
struct MyInt { val: int } struct MyInt { val: int }
impl Add<MyInt, MyInt> for MyInt { impl Add<MyInt, MyInt> for MyInt {

View file

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Foo(int); struct Foo(int);
#[deriving(Eq)] #[deriving(Eq, Show)]
struct Bar(int, int); struct Bar(int, int);
pub fn main() { pub fn main() {

View file

@ -13,7 +13,7 @@ use std::cmp::Eq;
fn sendable() { fn sendable() {
fn f<T:Send + Eq>(i: T, j: T) { fn f<T:Send + Eq>(i: T, j: T) {
assert_eq!(i, j); assert!(i == j);
} }
fn g<T:Send + Eq>(i: T, j: T) { fn g<T:Send + Eq>(i: T, j: T) {
@ -31,7 +31,7 @@ fn sendable() {
fn copyable() { fn copyable() {
fn f<T:Eq>(i: T, j: T) { fn f<T:Eq>(i: T, j: T) {
assert_eq!(i, j); assert!(i == j);
} }
fn g<T:Eq>(i: T, j: T) { fn g<T:Eq>(i: T, j: T) {
@ -49,7 +49,7 @@ fn copyable() {
fn noncopyable() { fn noncopyable() {
fn f<T:Eq>(i: T, j: T) { fn f<T:Eq>(i: T, j: T) {
assert_eq!(i, j); assert!(i == j);
} }
fn g<T:Eq>(i: T, j: T) { fn g<T:Eq>(i: T, j: T) {

View file

@ -13,7 +13,7 @@ pub fn main() {
match x { match x {
[2, _, _] => fail!(), [2, _, _] => fail!(),
[1, a, b] => { [1, a, b] => {
assert_eq!([a, b], [2, 3]); assert!([a, b] == [2, 3]);
} }
[_, _, _] => fail!(), [_, _, _] => fail!(),
} }