extra: Remove usage of fmt!
This commit is contained in:
parent
a8ba31dbf3
commit
7e709bfd0d
36 changed files with 424 additions and 421 deletions
|
@ -255,7 +255,7 @@ impl<T:Send> MutexArc<T> {
|
||||||
let inner = x.unwrap();
|
let inner = x.unwrap();
|
||||||
let MutexArcInner { failed: failed, data: data, _ } = inner;
|
let MutexArcInner { failed: failed, data: data, _ } = inner;
|
||||||
if failed {
|
if failed {
|
||||||
fail!(~"Can't unwrap poisoned MutexArc - another task failed inside!");
|
fail2!("Can't unwrap poisoned MutexArc - another task failed inside!");
|
||||||
}
|
}
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
@ -300,9 +300,9 @@ impl<T:Freeze + Send> MutexArc<T> {
|
||||||
fn check_poison(is_mutex: bool, failed: bool) {
|
fn check_poison(is_mutex: bool, failed: bool) {
|
||||||
if failed {
|
if failed {
|
||||||
if is_mutex {
|
if is_mutex {
|
||||||
fail!("Poisoned MutexArc - another task failed inside!");
|
fail2!("Poisoned MutexArc - another task failed inside!");
|
||||||
} else {
|
} else {
|
||||||
fail!("Poisoned rw_arc - another task failed inside!");
|
fail2!("Poisoned rw_arc - another task failed inside!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ impl<T:Freeze + Send> RWArc<T> {
|
||||||
let inner = x.unwrap();
|
let inner = x.unwrap();
|
||||||
let RWArcInner { failed: failed, data: data, _ } = inner;
|
let RWArcInner { failed: failed, data: data, _ } = inner;
|
||||||
if failed {
|
if failed {
|
||||||
fail!(~"Can't unwrap poisoned RWArc - another task failed inside!")
|
fail2!(~"Can't unwrap poisoned RWArc - another task failed inside!")
|
||||||
}
|
}
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ mod tests {
|
||||||
assert_eq!(arc_v.get()[2], 3);
|
assert_eq!(arc_v.get()[2], 3);
|
||||||
assert_eq!(arc_v.get()[4], 5);
|
assert_eq!(arc_v.get()[4], 5);
|
||||||
|
|
||||||
info!(arc_v);
|
info2!("{:?}", arc_v);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -127,7 +127,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
|
||||||
|
|
||||||
let start = round_up_to(after_tydesc, align);
|
let start = round_up_to(after_tydesc, align);
|
||||||
|
|
||||||
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
|
//debug2!("freeing object: idx = {}, size = {}, align = {}, done = {}",
|
||||||
// start, size, align, is_done);
|
// start, size, align, is_done);
|
||||||
if is_done {
|
if is_done {
|
||||||
((*tydesc).drop_glue)(ptr::offset(buf, start as int) as *i8);
|
((*tydesc).drop_glue)(ptr::offset(buf, start as int) as *i8);
|
||||||
|
@ -176,7 +176,7 @@ impl Arena {
|
||||||
}
|
}
|
||||||
this.pod_head.fill = end;
|
this.pod_head.fill = end;
|
||||||
|
|
||||||
//debug!("idx = %u, size = %u, align = %u, fill = %u",
|
//debug2!("idx = {}, size = {}, align = {}, fill = {}",
|
||||||
// start, n_bytes, align, head.fill);
|
// start, n_bytes, align, head.fill);
|
||||||
|
|
||||||
ptr::offset(vec::raw::to_ptr(this.pod_head.data), start as int)
|
ptr::offset(vec::raw::to_ptr(this.pod_head.data), start as int)
|
||||||
|
@ -232,7 +232,7 @@ impl Arena {
|
||||||
let head = transmute_mut_region(&mut self.head);
|
let head = transmute_mut_region(&mut self.head);
|
||||||
head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
|
head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
|
||||||
|
|
||||||
//debug!("idx = %u, size = %u, align = %u, fill = %u",
|
//debug2!("idx = {}, size = {}, align = {}, fill = {}",
|
||||||
// start, n_bytes, align, head.fill);
|
// start, n_bytes, align, head.fill);
|
||||||
|
|
||||||
let buf = vec::raw::to_ptr(self.head.data);
|
let buf = vec::raw::to_ptr(self.head.data);
|
||||||
|
@ -305,6 +305,6 @@ fn test_arena_destructors_fail() {
|
||||||
// Now, fail while allocating
|
// Now, fail while allocating
|
||||||
do arena.alloc::<@int> {
|
do arena.alloc::<@int> {
|
||||||
// Now fail.
|
// Now fail.
|
||||||
fail!();
|
fail2!();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl<'self> ToBase64 for &'self [u8] {
|
||||||
v.push('=' as u8);
|
v.push('=' as u8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => fail!("Algebra is broken, please alert the math police")
|
_ => fail2!("Algebra is broken, please alert the math police")
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -202,7 +202,7 @@ impl<'self> FromBase64 for &'self str {
|
||||||
'/'|'_' => buf |= 0x3F,
|
'/'|'_' => buf |= 0x3F,
|
||||||
'\r'|'\n' => loop,
|
'\r'|'\n' => loop,
|
||||||
'=' => break,
|
'=' => break,
|
||||||
_ => return Err(fmt!("Invalid character '%c' at position %u",
|
_ => return Err(format!("Invalid character '{}' at position {}",
|
||||||
self.char_at(idx), idx))
|
self.char_at(idx), idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ impl<'self> FromBase64 for &'self str {
|
||||||
|
|
||||||
for (idx, byte) in it {
|
for (idx, byte) in it {
|
||||||
if (byte as char) != '=' {
|
if (byte as char) != '=' {
|
||||||
return Err(fmt!("Invalid character '%c' at position %u",
|
return Err(format!("Invalid character '{}' at position {}",
|
||||||
self.char_at(idx), idx));
|
self.char_at(idx), idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ pub struct Bitv {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn die() -> ! {
|
fn die() -> ! {
|
||||||
fail!("Tried to do operation on bit vectors with different sizes");
|
fail2!("Tried to do operation on bit vectors with different sizes");
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bitv {
|
impl Bitv {
|
||||||
|
@ -1357,7 +1357,7 @@ mod tests {
|
||||||
let mut b = Bitv::new(14, true);
|
let mut b = Bitv::new(14, true);
|
||||||
b.clear();
|
b.clear();
|
||||||
do b.ones |i| {
|
do b.ones |i| {
|
||||||
fail!("found 1 at %?", i)
|
fail2!("found 1 at {:?}", i)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,7 +1366,7 @@ mod tests {
|
||||||
let mut b = Bitv::new(140, true);
|
let mut b = Bitv::new(140, true);
|
||||||
b.clear();
|
b.clear();
|
||||||
do b.ones |i| {
|
do b.ones |i| {
|
||||||
fail!("found 1 at %?", i)
|
fail2!("found 1 at {:?}", i)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ mod test {
|
||||||
let (port, chan) = rendezvous();
|
let (port, chan) = rendezvous();
|
||||||
do spawn_unlinked {
|
do spawn_unlinked {
|
||||||
chan.duplex_stream.send(()); // Can't access this field outside this module
|
chan.duplex_stream.send(()); // Can't access this field outside this module
|
||||||
fail!()
|
fail2!()
|
||||||
}
|
}
|
||||||
port.recv()
|
port.recv()
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ mod test {
|
||||||
let (port, chan) = rendezvous();
|
let (port, chan) = rendezvous();
|
||||||
do spawn_unlinked {
|
do spawn_unlinked {
|
||||||
port.duplex_stream.recv();
|
port.duplex_stream.recv();
|
||||||
fail!()
|
fail2!()
|
||||||
}
|
}
|
||||||
chan.try_send(());
|
chan.try_send(());
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ mod test {
|
||||||
let (port, chan) = rendezvous();
|
let (port, chan) = rendezvous();
|
||||||
do spawn_unlinked {
|
do spawn_unlinked {
|
||||||
port.duplex_stream.recv();
|
port.duplex_stream.recv();
|
||||||
fail!()
|
fail2!()
|
||||||
}
|
}
|
||||||
chan.send(());
|
chan.send(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,23 +109,23 @@ impl ToBits for u64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric
|
/// Adds the specified number of bytes to the bit count. fail2!() if this would cause numeric
|
||||||
/// overflow.
|
/// overflow.
|
||||||
pub fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T {
|
pub fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T {
|
||||||
let (new_high_bits, new_low_bits) = bytes.to_bits();
|
let (new_high_bits, new_low_bits) = bytes.to_bits();
|
||||||
|
|
||||||
if new_high_bits > Zero::zero() {
|
if new_high_bits > Zero::zero() {
|
||||||
fail!("Numeric overflow occured.")
|
fail2!("Numeric overflow occured.")
|
||||||
}
|
}
|
||||||
|
|
||||||
match bits.checked_add(&new_low_bits) {
|
match bits.checked_add(&new_low_bits) {
|
||||||
Some(x) => return x,
|
Some(x) => return x,
|
||||||
None => fail!("Numeric overflow occured.")
|
None => fail2!("Numeric overflow occured.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the specified number of bytes to the bit count, which is a tuple where the first element is
|
/// Adds the specified number of bytes to the bit count, which is a tuple where the first element is
|
||||||
/// the high order value. fail!() if this would cause numeric overflow.
|
/// the high order value. fail2!() if this would cause numeric overflow.
|
||||||
pub fn add_bytes_to_bits_tuple
|
pub fn add_bytes_to_bits_tuple
|
||||||
<T: Int + Unsigned + CheckedAdd + ToBits>
|
<T: Int + Unsigned + CheckedAdd + ToBits>
|
||||||
(bits: (T, T), bytes: T) -> (T, T) {
|
(bits: (T, T), bytes: T) -> (T, T) {
|
||||||
|
@ -144,7 +144,7 @@ pub fn add_bytes_to_bits_tuple
|
||||||
} else {
|
} else {
|
||||||
match hi.checked_add(&new_high_bits) {
|
match hi.checked_add(&new_high_bits) {
|
||||||
Some(y) => return (y, x),
|
Some(y) => return (y, x),
|
||||||
None => fail!("Numeric overflow occured.")
|
None => fail2!("Numeric overflow occured.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -152,7 +152,7 @@ pub fn add_bytes_to_bits_tuple
|
||||||
let one: T = One::one();
|
let one: T = One::one();
|
||||||
let z = match new_high_bits.checked_add(&one) {
|
let z = match new_high_bits.checked_add(&one) {
|
||||||
Some(w) => w,
|
Some(w) => w,
|
||||||
None => fail!("Numeric overflow occured.")
|
None => fail2!("Numeric overflow occured.")
|
||||||
};
|
};
|
||||||
match hi.checked_add(&z) {
|
match hi.checked_add(&z) {
|
||||||
// This re-executes the addition that was already performed earlier when overflow
|
// This re-executes the addition that was already performed earlier when overflow
|
||||||
|
@ -163,7 +163,7 @@ pub fn add_bytes_to_bits_tuple
|
||||||
// be Unsigned - overflow is not defined for Signed types. This function could be
|
// be Unsigned - overflow is not defined for Signed types. This function could be
|
||||||
// implemented for signed types as well if that were needed.
|
// implemented for signed types as well if that were needed.
|
||||||
Some(y) => return (y, low + new_low_bits),
|
Some(y) => return (y, low + new_low_bits),
|
||||||
None => fail!("Numeric overflow occured.")
|
None => fail2!("Numeric overflow occured.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,11 +632,11 @@ pub fn check_links<T>(list: &DList<T>) {
|
||||||
loop {
|
loop {
|
||||||
match (last_ptr, node_ptr.prev.resolve_immut()) {
|
match (last_ptr, node_ptr.prev.resolve_immut()) {
|
||||||
(None , None ) => {}
|
(None , None ) => {}
|
||||||
(None , _ ) => fail!("prev link for list_head"),
|
(None , _ ) => fail2!("prev link for list_head"),
|
||||||
(Some(p), Some(pptr)) => {
|
(Some(p), Some(pptr)) => {
|
||||||
assert_eq!(p as *Node<T>, pptr as *Node<T>);
|
assert_eq!(p as *Node<T>, pptr as *Node<T>);
|
||||||
}
|
}
|
||||||
_ => fail!("prev link is none, not good"),
|
_ => fail2!("prev link is none, not good"),
|
||||||
}
|
}
|
||||||
match node_ptr.next {
|
match node_ptr.next {
|
||||||
Some(ref next) => {
|
Some(ref next) => {
|
||||||
|
|
|
@ -138,7 +138,7 @@ pub mod reader {
|
||||||
(data[start + 3u] as uint),
|
(data[start + 3u] as uint),
|
||||||
next: start + 4u};
|
next: start + 4u};
|
||||||
}
|
}
|
||||||
fail!("vint too big");
|
fail2!("vint too big");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86")]
|
#[cfg(target_arch = "x86")]
|
||||||
|
@ -216,8 +216,8 @@ pub mod reader {
|
||||||
match maybe_get_doc(d, tg) {
|
match maybe_get_doc(d, tg) {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => {
|
None => {
|
||||||
error!("failed to find block with tag %u", tg);
|
error2!("failed to find block with tag {}", tg);
|
||||||
fail!();
|
fail2!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,20 +305,20 @@ pub mod reader {
|
||||||
self.pos = r_doc.end;
|
self.pos = r_doc.end;
|
||||||
let str = r_doc.as_str_slice();
|
let str = r_doc.as_str_slice();
|
||||||
if lbl != str {
|
if lbl != str {
|
||||||
fail!("Expected label %s but found %s", lbl, str);
|
fail2!("Expected label {} but found {}", lbl, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc {
|
fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc {
|
||||||
debug!(". next_doc(exp_tag=%?)", exp_tag);
|
debug2!(". next_doc(exp_tag={:?})", exp_tag);
|
||||||
if self.pos >= self.parent.end {
|
if self.pos >= self.parent.end {
|
||||||
fail!("no more documents in current node!");
|
fail2!("no more documents in current node!");
|
||||||
}
|
}
|
||||||
let TaggedDoc { tag: r_tag, doc: r_doc } =
|
let TaggedDoc { tag: r_tag, doc: r_doc } =
|
||||||
doc_at(self.parent.data, self.pos);
|
doc_at(self.parent.data, self.pos);
|
||||||
debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?",
|
debug2!("self.parent={}-{} self.pos={} r_tag={} r_doc={}-{}",
|
||||||
self.parent.start,
|
self.parent.start,
|
||||||
self.parent.end,
|
self.parent.end,
|
||||||
self.pos,
|
self.pos,
|
||||||
|
@ -326,10 +326,11 @@ pub mod reader {
|
||||||
r_doc.start,
|
r_doc.start,
|
||||||
r_doc.end);
|
r_doc.end);
|
||||||
if r_tag != (exp_tag as uint) {
|
if r_tag != (exp_tag as uint) {
|
||||||
fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag);
|
fail2!("expected EBML doc with tag {:?} but found tag {:?}",
|
||||||
|
exp_tag, r_tag);
|
||||||
}
|
}
|
||||||
if r_doc.end > self.parent.end {
|
if r_doc.end > self.parent.end {
|
||||||
fail!("invalid EBML, child extends to 0x%x, parent to 0x%x",
|
fail2!("invalid EBML, child extends to {:#x}, parent to {:#x}",
|
||||||
r_doc.end, self.parent.end);
|
r_doc.end, self.parent.end);
|
||||||
}
|
}
|
||||||
self.pos = r_doc.end;
|
self.pos = r_doc.end;
|
||||||
|
@ -351,7 +352,7 @@ pub mod reader {
|
||||||
|
|
||||||
fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint {
|
fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint {
|
||||||
let r = doc_as_u32(self.next_doc(exp_tag));
|
let r = doc_as_u32(self.next_doc(exp_tag));
|
||||||
debug!("_next_uint exp_tag=%? result=%?", exp_tag, r);
|
debug2!("_next_uint exp_tag={:?} result={}", exp_tag, r);
|
||||||
r as uint
|
r as uint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,7 +384,7 @@ pub mod reader {
|
||||||
fn read_uint(&mut self) -> uint {
|
fn read_uint(&mut self) -> uint {
|
||||||
let v = doc_as_u64(self.next_doc(EsUint));
|
let v = doc_as_u64(self.next_doc(EsUint));
|
||||||
if v > (::std::uint::max_value as u64) {
|
if v > (::std::uint::max_value as u64) {
|
||||||
fail!("uint %? too large for this architecture", v);
|
fail2!("uint {} too large for this architecture", v);
|
||||||
}
|
}
|
||||||
v as uint
|
v as uint
|
||||||
}
|
}
|
||||||
|
@ -403,8 +404,8 @@ pub mod reader {
|
||||||
fn read_int(&mut self) -> int {
|
fn read_int(&mut self) -> int {
|
||||||
let v = doc_as_u64(self.next_doc(EsInt)) as i64;
|
let v = doc_as_u64(self.next_doc(EsInt)) as i64;
|
||||||
if v > (int::max_value as i64) || v < (int::min_value as i64) {
|
if v > (int::max_value as i64) || v < (int::min_value as i64) {
|
||||||
debug!("FIXME #6122: Removing this makes this function miscompile");
|
debug2!("FIXME \\#6122: Removing this makes this function miscompile");
|
||||||
fail!("int %? out of range for this architecture", v);
|
fail2!("int {} out of range for this architecture", v);
|
||||||
}
|
}
|
||||||
v as int
|
v as int
|
||||||
}
|
}
|
||||||
|
@ -437,7 +438,7 @@ pub mod reader {
|
||||||
name: &str,
|
name: &str,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum(%s)", name);
|
debug2!("read_enum({})", name);
|
||||||
self._check_label(name);
|
self._check_label(name);
|
||||||
|
|
||||||
let doc = self.next_doc(EsEnum);
|
let doc = self.next_doc(EsEnum);
|
||||||
|
@ -457,9 +458,9 @@ pub mod reader {
|
||||||
_: &[&str],
|
_: &[&str],
|
||||||
f: &fn(&mut Decoder, uint) -> T)
|
f: &fn(&mut Decoder, uint) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_variant()");
|
debug2!("read_enum_variant()");
|
||||||
let idx = self._next_uint(EsEnumVid);
|
let idx = self._next_uint(EsEnumVid);
|
||||||
debug!(" idx=%u", idx);
|
debug2!(" idx={}", idx);
|
||||||
|
|
||||||
let doc = self.next_doc(EsEnumBody);
|
let doc = self.next_doc(EsEnumBody);
|
||||||
|
|
||||||
|
@ -477,7 +478,7 @@ pub mod reader {
|
||||||
fn read_enum_variant_arg<T>(&mut self,
|
fn read_enum_variant_arg<T>(&mut self,
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T) -> T {
|
f: &fn(&mut Decoder) -> T) -> T {
|
||||||
debug!("read_enum_variant_arg(idx=%u)", idx);
|
debug2!("read_enum_variant_arg(idx={})", idx);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,9 +486,9 @@ pub mod reader {
|
||||||
_: &[&str],
|
_: &[&str],
|
||||||
f: &fn(&mut Decoder, uint) -> T)
|
f: &fn(&mut Decoder, uint) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_struct_variant()");
|
debug2!("read_enum_struct_variant()");
|
||||||
let idx = self._next_uint(EsEnumVid);
|
let idx = self._next_uint(EsEnumVid);
|
||||||
debug!(" idx=%u", idx);
|
debug2!(" idx={}", idx);
|
||||||
|
|
||||||
let doc = self.next_doc(EsEnumBody);
|
let doc = self.next_doc(EsEnumBody);
|
||||||
|
|
||||||
|
@ -507,7 +508,7 @@ pub mod reader {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx);
|
debug2!("read_enum_struct_variant_arg(name={}, idx={})", name, idx);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +517,7 @@ pub mod reader {
|
||||||
_: uint,
|
_: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_struct(name=%s)", name);
|
debug2!("read_struct(name={})", name);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,19 +526,19 @@ pub mod reader {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_struct_field(name=%?, idx=%u)", name, idx);
|
debug2!("read_struct_field(name={}, idx={})", name, idx);
|
||||||
self._check_label(name);
|
self._check_label(name);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
||||||
debug!("read_tuple()");
|
debug2!("read_tuple()");
|
||||||
self.read_seq(f)
|
self.read_seq(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_tuple_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
|
fn read_tuple_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_tuple_arg(idx=%u)", idx);
|
debug2!("read_tuple_arg(idx={})", idx);
|
||||||
self.read_seq_elt(idx, f)
|
self.read_seq_elt(idx, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +546,7 @@ pub mod reader {
|
||||||
name: &str,
|
name: &str,
|
||||||
f: &fn(&mut Decoder, uint) -> T)
|
f: &fn(&mut Decoder, uint) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_tuple_struct(name=%?)", name);
|
debug2!("read_tuple_struct(name={})", name);
|
||||||
self.read_tuple(f)
|
self.read_tuple(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,43 +554,43 @@ pub mod reader {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_tuple_struct_arg(idx=%u)", idx);
|
debug2!("read_tuple_struct_arg(idx={})", idx);
|
||||||
self.read_tuple_arg(idx, f)
|
self.read_tuple_arg(idx, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
|
fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
|
||||||
debug!("read_option()");
|
debug2!("read_option()");
|
||||||
do self.read_enum("Option") |this| {
|
do self.read_enum("Option") |this| {
|
||||||
do this.read_enum_variant(["None", "Some"]) |this, idx| {
|
do this.read_enum_variant(["None", "Some"]) |this, idx| {
|
||||||
match idx {
|
match idx {
|
||||||
0 => f(this, false),
|
0 => f(this, false),
|
||||||
1 => f(this, true),
|
1 => f(this, true),
|
||||||
_ => fail!(),
|
_ => fail2!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
||||||
debug!("read_seq()");
|
debug2!("read_seq()");
|
||||||
do self.push_doc(EsVec) |d| {
|
do self.push_doc(EsVec) |d| {
|
||||||
let len = d._next_uint(EsVecLen);
|
let len = d._next_uint(EsVecLen);
|
||||||
debug!(" len=%u", len);
|
debug2!(" len={}", len);
|
||||||
f(d, len)
|
f(d, len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
|
fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_seq_elt(idx=%u)", idx);
|
debug2!("read_seq_elt(idx={})", idx);
|
||||||
self.push_doc(EsVecElt, f)
|
self.push_doc(EsVecElt, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
||||||
debug!("read_map()");
|
debug2!("read_map()");
|
||||||
do self.push_doc(EsMap) |d| {
|
do self.push_doc(EsMap) |d| {
|
||||||
let len = d._next_uint(EsMapLen);
|
let len = d._next_uint(EsMapLen);
|
||||||
debug!(" len=%u", len);
|
debug2!(" len={}", len);
|
||||||
f(d, len)
|
f(d, len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,7 +599,7 @@ pub mod reader {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_map_elt_key(idx=%u)", idx);
|
debug2!("read_map_elt_key(idx={})", idx);
|
||||||
self.push_doc(EsMapKey, f)
|
self.push_doc(EsMapKey, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +607,7 @@ pub mod reader {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_map_elt_val(idx=%u)", idx);
|
debug2!("read_map_elt_val(idx={})", idx);
|
||||||
self.push_doc(EsMapVal, f)
|
self.push_doc(EsMapVal, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -642,7 +643,7 @@ pub mod writer {
|
||||||
n as u8]),
|
n as u8]),
|
||||||
4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
|
4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
|
||||||
(n >> 8_u) as u8, n as u8]),
|
(n >> 8_u) as u8, n as u8]),
|
||||||
_ => fail!("vint to write too big: %?", n)
|
_ => fail2!("vint to write too big: {}", n)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +652,7 @@ pub mod writer {
|
||||||
if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; }
|
if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; }
|
||||||
if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; }
|
if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; }
|
||||||
if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; }
|
if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; }
|
||||||
fail!("vint to write too big: %?", n);
|
fail2!("vint to write too big: {}", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Encoder(w: @io::Writer) -> Encoder {
|
pub fn Encoder(w: @io::Writer) -> Encoder {
|
||||||
|
@ -665,7 +666,7 @@ pub mod writer {
|
||||||
// FIXME (#2741): Provide a function to write the standard ebml header.
|
// FIXME (#2741): Provide a function to write the standard ebml header.
|
||||||
impl Encoder {
|
impl Encoder {
|
||||||
pub fn start_tag(&mut self, tag_id: uint) {
|
pub fn start_tag(&mut self, tag_id: uint) {
|
||||||
debug!("Start tag %u", tag_id);
|
debug2!("Start tag {}", tag_id);
|
||||||
|
|
||||||
// Write the enum ID:
|
// Write the enum ID:
|
||||||
write_vuint(self.writer, tag_id);
|
write_vuint(self.writer, tag_id);
|
||||||
|
@ -684,7 +685,7 @@ pub mod writer {
|
||||||
write_sized_vuint(self.writer, size, 4u);
|
write_sized_vuint(self.writer, size, 4u);
|
||||||
self.writer.seek(cur_pos as int, io::SeekSet);
|
self.writer.seek(cur_pos as int, io::SeekSet);
|
||||||
|
|
||||||
debug!("End tag (size = %u)", size);
|
debug2!("End tag (size = {})", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wr_tag(&mut self, tag_id: uint, blk: &fn()) {
|
pub fn wr_tag(&mut self, tag_id: uint, blk: &fn()) {
|
||||||
|
@ -748,12 +749,12 @@ pub mod writer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wr_bytes(&mut self, b: &[u8]) {
|
pub fn wr_bytes(&mut self, b: &[u8]) {
|
||||||
debug!("Write %u bytes", b.len());
|
debug2!("Write {} bytes", b.len());
|
||||||
self.writer.write(b);
|
self.writer.write(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wr_str(&mut self, s: &str) {
|
pub fn wr_str(&mut self, s: &str) {
|
||||||
debug!("Write str: %?", s);
|
debug2!("Write str: {}", s);
|
||||||
self.writer.write(s.as_bytes());
|
self.writer.write(s.as_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -977,7 +978,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_option_int() {
|
fn test_option_int() {
|
||||||
fn test_v(v: Option<int>) {
|
fn test_v(v: Option<int>) {
|
||||||
debug!("v == %?", v);
|
debug2!("v == {:?}", v);
|
||||||
let bytes = do io::with_bytes_writer |wr| {
|
let bytes = do io::with_bytes_writer |wr| {
|
||||||
let mut ebml_w = writer::Encoder(wr);
|
let mut ebml_w = writer::Encoder(wr);
|
||||||
v.encode(&mut ebml_w)
|
v.encode(&mut ebml_w)
|
||||||
|
@ -985,7 +986,7 @@ mod tests {
|
||||||
let ebml_doc = reader::Doc(@bytes);
|
let ebml_doc = reader::Doc(@bytes);
|
||||||
let mut deser = reader::Decoder(ebml_doc);
|
let mut deser = reader::Decoder(ebml_doc);
|
||||||
let v1 = serialize::Decodable::decode(&mut deser);
|
let v1 = serialize::Decodable::decode(&mut deser);
|
||||||
debug!("v1 == %?", v1);
|
debug2!("v1 == {:?}", v1);
|
||||||
assert_eq!(v, v1);
|
assert_eq!(v, v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ to handle any `FileInput` structs. E.g. a simple `cat` program
|
||||||
or a program that numbers lines after concatenating two files
|
or a program that numbers lines after concatenating two files
|
||||||
|
|
||||||
for input_vec_state(make_path_option_vec([~"a.txt", ~"b.txt"])) |line, state| {
|
for input_vec_state(make_path_option_vec([~"a.txt", ~"b.txt"])) |line, state| {
|
||||||
io::println(fmt!("%u: %s", state.line_num,
|
io::println(format!("{}: %s", state.line_num,
|
||||||
line));
|
line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ total line count).
|
||||||
input.next_file(); // skip!
|
input.next_file(); // skip!
|
||||||
|
|
||||||
for input.each_line_state |line, state| {
|
for input.each_line_state |line, state| {
|
||||||
io::println(fmt!("%u: %s", state.line_num_file,
|
io::println(format!("{}: %s", state.line_num_file,
|
||||||
line))
|
line))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,11 +449,11 @@ mod test {
|
||||||
fn test_fileinput_read_byte() {
|
fn test_fileinput_read_byte() {
|
||||||
let filenames = make_path_option_vec(vec::from_fn(
|
let filenames = make_path_option_vec(vec::from_fn(
|
||||||
3,
|
3,
|
||||||
|i| fmt!("tmp/lib-fileinput-test-fileinput-read-byte-%u.tmp", i)), true);
|
|i| format!("tmp/lib-fileinput-test-fileinput-read-byte-{}.tmp", i)), true);
|
||||||
|
|
||||||
// 3 files containing 0\n, 1\n, and 2\n respectively
|
// 3 files containing 0\n, 1\n, and 2\n respectively
|
||||||
for (i, filename) in filenames.iter().enumerate() {
|
for (i, filename) in filenames.iter().enumerate() {
|
||||||
make_file(filename.get_ref(), [fmt!("%u", i)]);
|
make_file(filename.get_ref(), [format!("{}", i)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let fi = FileInput::from_vec(filenames.clone());
|
let fi = FileInput::from_vec(filenames.clone());
|
||||||
|
@ -479,11 +479,11 @@ mod test {
|
||||||
fn test_fileinput_read() {
|
fn test_fileinput_read() {
|
||||||
let filenames = make_path_option_vec(vec::from_fn(
|
let filenames = make_path_option_vec(vec::from_fn(
|
||||||
3,
|
3,
|
||||||
|i| fmt!("tmp/lib-fileinput-test-fileinput-read-%u.tmp", i)), true);
|
|i| format!("tmp/lib-fileinput-test-fileinput-read-{}.tmp", i)), true);
|
||||||
|
|
||||||
// 3 files containing 1\n, 2\n, and 3\n respectively
|
// 3 files containing 1\n, 2\n, and 3\n respectively
|
||||||
for (i, filename) in filenames.iter().enumerate() {
|
for (i, filename) in filenames.iter().enumerate() {
|
||||||
make_file(filename.get_ref(), [fmt!("%u", i)]);
|
make_file(filename.get_ref(), [format!("{}", i)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let fi = FileInput::from_vec(filenames);
|
let fi = FileInput::from_vec(filenames);
|
||||||
|
@ -500,13 +500,13 @@ mod test {
|
||||||
let mut all_lines = ~[];
|
let mut all_lines = ~[];
|
||||||
let filenames = make_path_option_vec(vec::from_fn(
|
let filenames = make_path_option_vec(vec::from_fn(
|
||||||
3,
|
3,
|
||||||
|i| fmt!("tmp/lib-fileinput-test-input-vec-%u.tmp", i)), true);
|
|i| format!("tmp/lib-fileinput-test-input-vec-{}.tmp", i)), true);
|
||||||
|
|
||||||
for (i, filename) in filenames.iter().enumerate() {
|
for (i, filename) in filenames.iter().enumerate() {
|
||||||
let contents =
|
let contents =
|
||||||
vec::from_fn(3, |j| fmt!("%u %u", i, j));
|
vec::from_fn(3, |j| format!("{} {}", i, j));
|
||||||
make_file(filename.get_ref(), contents);
|
make_file(filename.get_ref(), contents);
|
||||||
debug!("contents=%?", contents);
|
debug2!("contents={:?}", contents);
|
||||||
all_lines.push_all(contents);
|
all_lines.push_all(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,11 +522,11 @@ mod test {
|
||||||
fn test_input_vec_state() {
|
fn test_input_vec_state() {
|
||||||
let filenames = make_path_option_vec(vec::from_fn(
|
let filenames = make_path_option_vec(vec::from_fn(
|
||||||
3,
|
3,
|
||||||
|i| fmt!("tmp/lib-fileinput-test-input-vec-state-%u.tmp", i)),true);
|
|i| format!("tmp/lib-fileinput-test-input-vec-state-{}.tmp", i)),true);
|
||||||
|
|
||||||
for (i, filename) in filenames.iter().enumerate() {
|
for (i, filename) in filenames.iter().enumerate() {
|
||||||
let contents =
|
let contents =
|
||||||
vec::from_fn(3, |j| fmt!("%u %u", i, j + 1));
|
vec::from_fn(3, |j| format!("{} {}", i, j + 1));
|
||||||
make_file(filename.get_ref(), contents);
|
make_file(filename.get_ref(), contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ mod test {
|
||||||
fn test_empty_files() {
|
fn test_empty_files() {
|
||||||
let filenames = make_path_option_vec(vec::from_fn(
|
let filenames = make_path_option_vec(vec::from_fn(
|
||||||
3,
|
3,
|
||||||
|i| fmt!("tmp/lib-fileinput-test-empty-files-%u.tmp", i)),true);
|
|i| format!("tmp/lib-fileinput-test-empty-files-{}.tmp", i)),true);
|
||||||
|
|
||||||
make_file(filenames[0].get_ref(), [~"1", ~"2"]);
|
make_file(filenames[0].get_ref(), [~"1", ~"2"]);
|
||||||
make_file(filenames[1].get_ref(), []);
|
make_file(filenames[1].get_ref(), []);
|
||||||
|
@ -555,7 +555,7 @@ mod test {
|
||||||
let expected_path = match line {
|
let expected_path = match line {
|
||||||
"1" | "2" => filenames[0].clone(),
|
"1" | "2" => filenames[0].clone(),
|
||||||
"3" | "4" => filenames[2].clone(),
|
"3" | "4" => filenames[2].clone(),
|
||||||
_ => fail!("unexpected line")
|
_ => fail2!("unexpected line")
|
||||||
};
|
};
|
||||||
assert_eq!(state.current_path.clone(), expected_path);
|
assert_eq!(state.current_path.clone(), expected_path);
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -593,11 +593,11 @@ mod test {
|
||||||
fn test_next_file() {
|
fn test_next_file() {
|
||||||
let filenames = make_path_option_vec(vec::from_fn(
|
let filenames = make_path_option_vec(vec::from_fn(
|
||||||
3,
|
3,
|
||||||
|i| fmt!("tmp/lib-fileinput-test-next-file-%u.tmp", i)),true);
|
|i| format!("tmp/lib-fileinput-test-next-file-{}.tmp", i)),true);
|
||||||
|
|
||||||
for (i, filename) in filenames.iter().enumerate() {
|
for (i, filename) in filenames.iter().enumerate() {
|
||||||
let contents =
|
let contents =
|
||||||
vec::from_fn(3, |j| fmt!("%u %u", i, j + 1));
|
vec::from_fn(3, |j| format!("{} {}", i, j + 1));
|
||||||
make_file(filename.get_ref(), contents);
|
make_file(filename.get_ref(), contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +609,7 @@ mod test {
|
||||||
|
|
||||||
// read all lines from 1 (but don't read any from 2),
|
// read all lines from 1 (but don't read any from 2),
|
||||||
for i in range(1u, 4) {
|
for i in range(1u, 4) {
|
||||||
assert_eq!(input.read_line(), fmt!("1 %u", i));
|
assert_eq!(input.read_line(), format!("1 {}", i));
|
||||||
}
|
}
|
||||||
// 1 is finished, but 2 hasn't been started yet, so this will
|
// 1 is finished, but 2 hasn't been started yet, so this will
|
||||||
// just "skip" to the beginning of 2 (Python's fileinput does
|
// just "skip" to the beginning of 2 (Python's fileinput does
|
||||||
|
|
|
@ -121,11 +121,11 @@ mod tests {
|
||||||
do 2000.times {
|
do 2000.times {
|
||||||
input.push_all(r.choose(words));
|
input.push_all(r.choose(words));
|
||||||
}
|
}
|
||||||
debug!("de/inflate of %u bytes of random word-sequences",
|
debug2!("de/inflate of {} bytes of random word-sequences",
|
||||||
input.len());
|
input.len());
|
||||||
let cmp = deflate_bytes(input);
|
let cmp = deflate_bytes(input);
|
||||||
let out = inflate_bytes(cmp);
|
let out = inflate_bytes(cmp);
|
||||||
debug!("%u bytes deflated to %u (%.1f%% size)",
|
debug2!("{} bytes deflated to {} ({:.1f}% size)",
|
||||||
input.len(), cmp.len(),
|
input.len(), cmp.len(),
|
||||||
100.0 * ((cmp.len() as float) / (input.len() as float)));
|
100.0 * ((cmp.len() as float) / (input.len() as float)));
|
||||||
assert_eq!(input, out);
|
assert_eq!(input, out);
|
||||||
|
|
|
@ -261,14 +261,14 @@ impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
|
||||||
fn recv(&self) -> T {
|
fn recv(&self) -> T {
|
||||||
match self.try_recv() {
|
match self.try_recv() {
|
||||||
Some(val) => val,
|
Some(val) => val,
|
||||||
None => fail!("port is closed")
|
None => fail2!("port is closed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn try_recv(&self) -> Option<T> {
|
fn try_recv(&self) -> Option<T> {
|
||||||
let command = match self.byte_port.try_recv(CONTINUE.len()) {
|
let command = match self.byte_port.try_recv(CONTINUE.len()) {
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
None => {
|
None => {
|
||||||
warn!("flatpipe: broken pipe");
|
warn2!("flatpipe: broken pipe");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -279,7 +279,7 @@ impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
|
||||||
io::u64_from_be_bytes(bytes, 0, size_of::<u64>())
|
io::u64_from_be_bytes(bytes, 0, size_of::<u64>())
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
warn!("flatpipe: broken pipe");
|
warn2!("flatpipe: broken pipe");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -291,13 +291,13 @@ impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
|
||||||
Some(self.unflattener.unflatten(bytes))
|
Some(self.unflattener.unflatten(bytes))
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
warn!("flatpipe: broken pipe");
|
warn2!("flatpipe: broken pipe");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fail!("flatpipe: unrecognized command");
|
fail2!("flatpipe: unrecognized command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,7 @@ pub mod flatteners {
|
||||||
Ok(json) => {
|
Ok(json) => {
|
||||||
json::Decoder(json)
|
json::Decoder(json)
|
||||||
}
|
}
|
||||||
Err(e) => fail!("flatpipe: can't parse json: %?", e)
|
Err(e) => fail2!("flatpipe: can't parse json: {:?}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ pub mod bytepipes {
|
||||||
if left == 0 {
|
if left == 0 {
|
||||||
return Some(bytes);
|
return Some(bytes);
|
||||||
} else {
|
} else {
|
||||||
warn!("flatpipe: dropped %? broken bytes", left);
|
warn2!("flatpipe: dropped {} broken bytes", left);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ mod test {
|
||||||
let listen_res = do tcp::listen(
|
let listen_res = do tcp::listen(
|
||||||
addr.clone(), port, 128, iotask, |_kill_ch| {
|
addr.clone(), port, 128, iotask, |_kill_ch| {
|
||||||
// Tell the sender to initiate the connection
|
// Tell the sender to initiate the connection
|
||||||
debug!("listening");
|
debug2!("listening");
|
||||||
begin_connect_chan.send(())
|
begin_connect_chan.send(())
|
||||||
}) |new_conn, kill_ch| {
|
}) |new_conn, kill_ch| {
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ mod test {
|
||||||
// Wait for the server to start listening
|
// Wait for the server to start listening
|
||||||
begin_connect_port.recv();
|
begin_connect_port.recv();
|
||||||
|
|
||||||
debug!("connecting");
|
debug2!("connecting");
|
||||||
let iotask = &uv::global_loop::get();
|
let iotask = &uv::global_loop::get();
|
||||||
let connect_result = tcp::connect(addr.clone(), port, iotask);
|
let connect_result = tcp::connect(addr.clone(), port, iotask);
|
||||||
assert!(connect_result.is_ok());
|
assert!(connect_result.is_ok());
|
||||||
|
@ -831,7 +831,7 @@ mod test {
|
||||||
let chan = writer_chan(socket_buf);
|
let chan = writer_chan(socket_buf);
|
||||||
|
|
||||||
for i in range(0, 10) {
|
for i in range(0, 10) {
|
||||||
debug!("sending %?", i);
|
debug2!("sending {}", i);
|
||||||
chan.send(i)
|
chan.send(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -841,9 +841,9 @@ mod test {
|
||||||
// Wait for a connection
|
// Wait for a connection
|
||||||
let (conn, res_chan) = accept_port.recv();
|
let (conn, res_chan) = accept_port.recv();
|
||||||
|
|
||||||
debug!("accepting connection");
|
debug2!("accepting connection");
|
||||||
let accept_result = tcp::accept(conn);
|
let accept_result = tcp::accept(conn);
|
||||||
debug!("accepted");
|
debug2!("accepted");
|
||||||
assert!(accept_result.is_ok());
|
assert!(accept_result.is_ok());
|
||||||
let sock = result::unwrap(accept_result);
|
let sock = result::unwrap(accept_result);
|
||||||
res_chan.send(());
|
res_chan.send(());
|
||||||
|
@ -855,7 +855,7 @@ mod test {
|
||||||
|
|
||||||
for i in range(0, 10) {
|
for i in range(0, 10) {
|
||||||
let j = port.recv();
|
let j = port.recv();
|
||||||
debug!("received %?", j);
|
debug2!("received {:?}", j);
|
||||||
assert_eq!(i, j);
|
assert_eq!(i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<A> Future<A> {
|
||||||
let state = replace(&mut this.state, Evaluating);
|
let state = replace(&mut this.state, Evaluating);
|
||||||
match state {
|
match state {
|
||||||
Forced(v) => v,
|
Forced(v) => v,
|
||||||
_ => fail!( "Logic error." ),
|
_ => fail2!( "Logic error." ),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,10 +69,10 @@ impl<A> Future<A> {
|
||||||
*/
|
*/
|
||||||
match self.state {
|
match self.state {
|
||||||
Forced(ref v) => return v,
|
Forced(ref v) => return v,
|
||||||
Evaluating => fail!("Recursive forcing of future!"),
|
Evaluating => fail2!("Recursive forcing of future!"),
|
||||||
Pending(_) => {
|
Pending(_) => {
|
||||||
match replace(&mut self.state, Evaluating) {
|
match replace(&mut self.state, Evaluating) {
|
||||||
Forced(_) | Evaluating => fail!("Logic error."),
|
Forced(_) | Evaluating => fail2!("Logic error."),
|
||||||
Pending(f) => {
|
Pending(f) => {
|
||||||
self.state = Forced(f());
|
self.state = Forced(f());
|
||||||
self.get_ref()
|
self.get_ref()
|
||||||
|
@ -217,7 +217,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_futurefail() {
|
fn test_futurefail() {
|
||||||
let mut f = Future::spawn(|| fail!());
|
let mut f = Future::spawn(|| fail2!());
|
||||||
let _x: ~str = f.get();
|
let _x: ~str = f.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
//! ];
|
//! ];
|
||||||
//! let matches = match getopts(args.tail(), opts) {
|
//! let matches = match getopts(args.tail(), opts) {
|
||||||
//! Ok(m) => { m }
|
//! Ok(m) => { m }
|
||||||
//! Err(f) => { fail!(f.to_err_msg()) }
|
//! Err(f) => { fail2!(f.to_err_msg()) }
|
||||||
//! };
|
//! };
|
||||||
//! if matches.opt_present("h") || matches.opt_present("help") {
|
//! if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
//! print_usage(program, opts);
|
//! print_usage(program, opts);
|
||||||
|
@ -185,7 +185,7 @@ impl Matches {
|
||||||
pub fn opt_vals(&self, nm: &str) -> ~[Optval] {
|
pub fn opt_vals(&self, nm: &str) -> ~[Optval] {
|
||||||
match find_opt(self.opts, Name::from_str(nm)) {
|
match find_opt(self.opts, Name::from_str(nm)) {
|
||||||
Some(id) => self.vals[id].clone(),
|
Some(id) => self.vals[id].clone(),
|
||||||
None => fail!("No option '%s' defined", nm)
|
None => fail2!("No option '{}' defined", nm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,19 +365,19 @@ impl Fail_ {
|
||||||
pub fn to_err_msg(self) -> ~str {
|
pub fn to_err_msg(self) -> ~str {
|
||||||
match self {
|
match self {
|
||||||
ArgumentMissing(ref nm) => {
|
ArgumentMissing(ref nm) => {
|
||||||
fmt!("Argument to option '%s' missing.", *nm)
|
format!("Argument to option '{}' missing.", *nm)
|
||||||
}
|
}
|
||||||
UnrecognizedOption(ref nm) => {
|
UnrecognizedOption(ref nm) => {
|
||||||
fmt!("Unrecognized option: '%s'.", *nm)
|
format!("Unrecognized option: '{}'.", *nm)
|
||||||
}
|
}
|
||||||
OptionMissing(ref nm) => {
|
OptionMissing(ref nm) => {
|
||||||
fmt!("Required option '%s' missing.", *nm)
|
format!("Required option '{}' missing.", *nm)
|
||||||
}
|
}
|
||||||
OptionDuplicated(ref nm) => {
|
OptionDuplicated(ref nm) => {
|
||||||
fmt!("Option '%s' given more than once.", *nm)
|
format!("Option '{}' given more than once.", *nm)
|
||||||
}
|
}
|
||||||
UnexpectedArgument(ref nm) => {
|
UnexpectedArgument(ref nm) => {
|
||||||
fmt!("Option '%s' does not take an argument.", *nm)
|
format!("Option '{}' does not take an argument.", *nm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ pub mod groups {
|
||||||
} = (*self).clone();
|
} = (*self).clone();
|
||||||
|
|
||||||
match (short_name.len(), long_name.len()) {
|
match (short_name.len(), long_name.len()) {
|
||||||
(0,0) => fail!("this long-format option was given no name"),
|
(0,0) => fail2!("this long-format option was given no name"),
|
||||||
(0,_) => Opt {
|
(0,_) => Opt {
|
||||||
name: Long((long_name)),
|
name: Long((long_name)),
|
||||||
hasarg: hasarg,
|
hasarg: hasarg,
|
||||||
|
@ -577,7 +577,7 @@ pub mod groups {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
(_,_) => fail!("something is wrong with the long-form opt")
|
(_,_) => fail2!("something is wrong with the long-form opt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -696,7 +696,7 @@ pub mod groups {
|
||||||
row.push_str(short_name);
|
row.push_str(short_name);
|
||||||
row.push_char(' ');
|
row.push_char(' ');
|
||||||
}
|
}
|
||||||
_ => fail!("the short name should only be 1 ascii char long"),
|
_ => fail2!("the short name should only be 1 ascii char long"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// long option
|
// long option
|
||||||
|
@ -752,7 +752,7 @@ pub mod groups {
|
||||||
row
|
row
|
||||||
});
|
});
|
||||||
|
|
||||||
fmt!("%s\n\nOptions:\n%s\n", brief, rows.collect::<~[~str]>().connect("\n"))
|
format!("{}\n\nOptions:\n{}\n", brief, rows.collect::<~[~str]>().connect("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Splits a string into substrings with possibly internal whitespace,
|
/// Splits a string into substrings with possibly internal whitespace,
|
||||||
|
@ -810,7 +810,7 @@ pub mod groups {
|
||||||
|
|
||||||
(B, Cr, UnderLim) => { B }
|
(B, Cr, UnderLim) => { B }
|
||||||
(B, Cr, OverLim) if (i - last_start + 1) > lim
|
(B, Cr, OverLim) if (i - last_start + 1) > lim
|
||||||
=> fail!("word starting with %? longer than limit!",
|
=> fail2!("word starting with {} longer than limit!",
|
||||||
ss.slice(last_start, i + 1)),
|
ss.slice(last_start, i + 1)),
|
||||||
(B, Cr, OverLim) => { slice(); slice_start = last_start; B }
|
(B, Cr, OverLim) => { slice(); slice_start = last_start; B }
|
||||||
(B, Ws, UnderLim) => { last_end = i; C }
|
(B, Ws, UnderLim) => { last_end = i; C }
|
||||||
|
@ -883,7 +883,7 @@ mod tests {
|
||||||
assert!(m.opt_present("test"));
|
assert!(m.opt_present("test"));
|
||||||
assert_eq!(m.opt_str("test").unwrap(), ~"20");
|
assert_eq!(m.opt_str("test").unwrap(), ~"20");
|
||||||
}
|
}
|
||||||
_ => { fail!("test_reqopt_long failed"); }
|
_ => { fail2!("test_reqopt_long failed"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +894,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionMissing_),
|
Err(f) => check_fail_type(f, OptionMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,7 +905,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, ArgumentMissing_),
|
Err(f) => check_fail_type(f, ArgumentMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionDuplicated_),
|
Err(f) => check_fail_type(f, OptionDuplicated_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,7 +930,7 @@ mod tests {
|
||||||
assert!(m.opt_present("t"));
|
assert!(m.opt_present("t"));
|
||||||
assert_eq!(m.opt_str("t").unwrap(), ~"20");
|
assert_eq!(m.opt_str("t").unwrap(), ~"20");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionMissing_),
|
Err(f) => check_fail_type(f, OptionMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, ArgumentMissing_),
|
Err(f) => check_fail_type(f, ArgumentMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,7 +963,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionDuplicated_),
|
Err(f) => check_fail_type(f, OptionDuplicated_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +979,7 @@ mod tests {
|
||||||
assert!(m.opt_present("test"));
|
assert!(m.opt_present("test"));
|
||||||
assert_eq!(m.opt_str("test").unwrap(), ~"20");
|
assert_eq!(m.opt_str("test").unwrap(), ~"20");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(!m.opt_present("test")),
|
Ok(ref m) => assert!(!m.opt_present("test")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,7 +1001,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, ArgumentMissing_),
|
Err(f) => check_fail_type(f, ArgumentMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1012,7 +1012,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionDuplicated_),
|
Err(f) => check_fail_type(f, OptionDuplicated_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1026,7 +1026,7 @@ mod tests {
|
||||||
assert!((m.opt_present("t")));
|
assert!((m.opt_present("t")));
|
||||||
assert_eq!(m.opt_str("t").unwrap(), ~"20");
|
assert_eq!(m.opt_str("t").unwrap(), ~"20");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,7 +1037,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(!m.opt_present("t")),
|
Ok(ref m) => assert!(!m.opt_present("t")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, ArgumentMissing_),
|
Err(f) => check_fail_type(f, ArgumentMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,7 +1059,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionDuplicated_),
|
Err(f) => check_fail_type(f, OptionDuplicated_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,7 +1072,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(m.opt_present("test")),
|
Ok(ref m) => assert!(m.opt_present("test")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1083,7 +1083,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(!m.opt_present("test")),
|
Ok(ref m) => assert!(!m.opt_present("test")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,10 +1094,10 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
error!(f.clone().to_err_msg());
|
error2!("{:?}", f.clone().to_err_msg());
|
||||||
check_fail_type(f, UnexpectedArgument_);
|
check_fail_type(f, UnexpectedArgument_);
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,7 +1108,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionDuplicated_),
|
Err(f) => check_fail_type(f, OptionDuplicated_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(m.opt_present("t")),
|
Ok(ref m) => assert!(m.opt_present("t")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,7 +1130,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(!m.opt_present("t")),
|
Ok(ref m) => assert!(!m.opt_present("t")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,7 +1145,7 @@ mod tests {
|
||||||
|
|
||||||
assert!(m.free[0] == ~"20");
|
assert!(m.free[0] == ~"20");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1156,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, OptionDuplicated_),
|
Err(f) => check_fail_type(f, OptionDuplicated_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1170,7 @@ mod tests {
|
||||||
Ok(ref m) => {
|
Ok(ref m) => {
|
||||||
assert_eq!(m.opt_count("v"), 1);
|
assert_eq!(m.opt_count("v"), 1);
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ mod tests {
|
||||||
Ok(ref m) => {
|
Ok(ref m) => {
|
||||||
assert_eq!(m.opt_count("v"), 2);
|
assert_eq!(m.opt_count("v"), 2);
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,7 +1196,7 @@ mod tests {
|
||||||
Ok(ref m) => {
|
Ok(ref m) => {
|
||||||
assert_eq!(m.opt_count("v"), 2);
|
assert_eq!(m.opt_count("v"), 2);
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,7 +1209,7 @@ mod tests {
|
||||||
Ok(ref m) => {
|
Ok(ref m) => {
|
||||||
assert_eq!(m.opt_count("verbose"), 1);
|
assert_eq!(m.opt_count("verbose"), 1);
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,7 +1222,7 @@ mod tests {
|
||||||
Ok(ref m) => {
|
Ok(ref m) => {
|
||||||
assert_eq!(m.opt_count("verbose"), 2);
|
assert_eq!(m.opt_count("verbose"), 2);
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1237,7 +1237,7 @@ mod tests {
|
||||||
assert!((m.opt_present("test")));
|
assert!((m.opt_present("test")));
|
||||||
assert_eq!(m.opt_str("test").unwrap(), ~"20");
|
assert_eq!(m.opt_str("test").unwrap(), ~"20");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(!m.opt_present("test")),
|
Ok(ref m) => assert!(!m.opt_present("test")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, ArgumentMissing_),
|
Err(f) => check_fail_type(f, ArgumentMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,7 +1276,7 @@ mod tests {
|
||||||
assert!(pair[0] == ~"20");
|
assert!(pair[0] == ~"20");
|
||||||
assert!(pair[1] == ~"30");
|
assert!(pair[1] == ~"30");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,7 +1290,7 @@ mod tests {
|
||||||
assert!((m.opt_present("t")));
|
assert!((m.opt_present("t")));
|
||||||
assert_eq!(m.opt_str("t").unwrap(), ~"20");
|
assert_eq!(m.opt_str("t").unwrap(), ~"20");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1301,7 +1301,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Ok(ref m) => assert!(!m.opt_present("t")),
|
Ok(ref m) => assert!(!m.opt_present("t")),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,7 +1312,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, ArgumentMissing_),
|
Err(f) => check_fail_type(f, ArgumentMissing_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,7 +1329,7 @@ mod tests {
|
||||||
assert!(pair[0] == ~"20");
|
assert!(pair[0] == ~"20");
|
||||||
assert!(pair[1] == ~"30");
|
assert!(pair[1] == ~"30");
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1340,7 +1340,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, UnrecognizedOption_),
|
Err(f) => check_fail_type(f, UnrecognizedOption_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1351,7 +1351,7 @@ mod tests {
|
||||||
let rs = getopts(args, opts);
|
let rs = getopts(args, opts);
|
||||||
match rs {
|
match rs {
|
||||||
Err(f) => check_fail_type(f, UnrecognizedOption_),
|
Err(f) => check_fail_type(f, UnrecognizedOption_),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1383,7 +1383,7 @@ mod tests {
|
||||||
assert!(pair[1] == ~"-60 70");
|
assert!(pair[1] == ~"-60 70");
|
||||||
assert!((!m.opt_present("notpresent")));
|
assert!((!m.opt_present("notpresent")));
|
||||||
}
|
}
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1394,7 +1394,7 @@ mod tests {
|
||||||
let args_single = ~[~"-e", ~"foo"];
|
let args_single = ~[~"-e", ~"foo"];
|
||||||
let matches_single = &match getopts(args_single, opts) {
|
let matches_single = &match getopts(args_single, opts) {
|
||||||
result::Ok(m) => m,
|
result::Ok(m) => m,
|
||||||
result::Err(_) => fail!()
|
result::Err(_) => fail2!()
|
||||||
};
|
};
|
||||||
assert!(matches_single.opts_present([~"e"]));
|
assert!(matches_single.opts_present([~"e"]));
|
||||||
assert!(matches_single.opts_present([~"encrypt", ~"e"]));
|
assert!(matches_single.opts_present([~"encrypt", ~"e"]));
|
||||||
|
@ -1410,7 +1410,7 @@ mod tests {
|
||||||
let args_both = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
|
let args_both = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
|
||||||
let matches_both = &match getopts(args_both, opts) {
|
let matches_both = &match getopts(args_both, opts) {
|
||||||
result::Ok(m) => m,
|
result::Ok(m) => m,
|
||||||
result::Err(_) => fail!()
|
result::Err(_) => fail2!()
|
||||||
};
|
};
|
||||||
assert!(matches_both.opts_present([~"e"]));
|
assert!(matches_both.opts_present([~"e"]));
|
||||||
assert!(matches_both.opts_present([~"encrypt"]));
|
assert!(matches_both.opts_present([~"encrypt"]));
|
||||||
|
@ -1432,7 +1432,7 @@ mod tests {
|
||||||
let opts = ~[optmulti("L"), optmulti("M")];
|
let opts = ~[optmulti("L"), optmulti("M")];
|
||||||
let matches = &match getopts(args, opts) {
|
let matches = &match getopts(args, opts) {
|
||||||
result::Ok(m) => m,
|
result::Ok(m) => m,
|
||||||
result::Err(_) => fail!()
|
result::Err(_) => fail2!()
|
||||||
};
|
};
|
||||||
assert!(matches.opts_present([~"L"]));
|
assert!(matches.opts_present([~"L"]));
|
||||||
assert_eq!(matches.opts_str([~"L"]).unwrap(), ~"foo");
|
assert_eq!(matches.opts_str([~"L"]).unwrap(), ~"foo");
|
||||||
|
@ -1575,8 +1575,8 @@ Options:
|
||||||
|
|
||||||
let generated_usage = groups::usage("Usage: fruits", optgroups);
|
let generated_usage = groups::usage("Usage: fruits", optgroups);
|
||||||
|
|
||||||
debug!("expected: <<%s>>", expected);
|
debug2!("expected: <<{}>>", expected);
|
||||||
debug!("generated: <<%s>>", generated_usage);
|
debug2!("generated: <<{}>>", generated_usage);
|
||||||
assert_eq!(generated_usage, expected);
|
assert_eq!(generated_usage, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1603,8 +1603,8 @@ Options:
|
||||||
|
|
||||||
let usage = groups::usage("Usage: fruits", optgroups);
|
let usage = groups::usage("Usage: fruits", optgroups);
|
||||||
|
|
||||||
debug!("expected: <<%s>>", expected);
|
debug2!("expected: <<{}>>", expected);
|
||||||
debug!("generated: <<%s>>", usage);
|
debug2!("generated: <<{}>>", usage);
|
||||||
assert!(usage == expected)
|
assert!(usage == expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1630,8 +1630,8 @@ Options:
|
||||||
|
|
||||||
let usage = groups::usage("Usage: fruits", optgroups);
|
let usage = groups::usage("Usage: fruits", optgroups);
|
||||||
|
|
||||||
debug!("expected: <<%s>>", expected);
|
debug2!("expected: <<{}>>", expected);
|
||||||
debug!("generated: <<%s>>", usage);
|
debug2!("generated: <<{}>>", usage);
|
||||||
assert!(usage == expected)
|
assert!(usage == expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,13 +552,13 @@ mod test {
|
||||||
|
|
||||||
let pat = Pattern::new("a[0-9]b");
|
let pat = Pattern::new("a[0-9]b");
|
||||||
for i in range(0, 10) {
|
for i in range(0, 10) {
|
||||||
assert!(pat.matches(fmt!("a%db", i)));
|
assert!(pat.matches(format!("a{}b", i)));
|
||||||
}
|
}
|
||||||
assert!(!pat.matches("a_b"));
|
assert!(!pat.matches("a_b"));
|
||||||
|
|
||||||
let pat = Pattern::new("a[!0-9]b");
|
let pat = Pattern::new("a[!0-9]b");
|
||||||
for i in range(0, 10) {
|
for i in range(0, 10) {
|
||||||
assert!(!pat.matches(fmt!("a%db", i)));
|
assert!(!pat.matches(format!("a{}b", i)));
|
||||||
}
|
}
|
||||||
assert!(pat.matches("a_b"));
|
assert!(pat.matches("a_b"));
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@ impl<'self> FromHex for &'self str {
|
||||||
buf >>= 4;
|
buf >>= 4;
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
_ => return Err(fmt!("Invalid character '%c' at position %u",
|
_ => return Err(format!("Invalid character '{}' at position {}",
|
||||||
self.char_at(idx), idx))
|
self.char_at(idx), idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
modulus += 1;
|
modulus += 1;
|
||||||
|
@ -158,15 +158,15 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_to_hex_all_bytes() {
|
pub fn test_to_hex_all_bytes() {
|
||||||
for i in range(0, 256) {
|
for i in range(0, 256) {
|
||||||
assert_eq!([i as u8].to_hex(), fmt!("%02x", i as uint));
|
assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_from_hex_all_bytes() {
|
pub fn test_from_hex_all_bytes() {
|
||||||
for i in range(0, 256) {
|
for i in range(0, 256) {
|
||||||
assert_eq!(fmt!("%02x", i as uint).from_hex().unwrap(), ~[i as u8]);
|
assert_eq!(format!("{:02x}", i as uint).from_hex().unwrap(), ~[i as u8]);
|
||||||
assert_eq!(fmt!("%02X", i as uint).from_hex().unwrap(), ~[i as u8]);
|
assert_eq!(format!("{:02X}", i as uint).from_hex().unwrap(), ~[i as u8]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -885,10 +885,10 @@ pub fn Decoder(json: Json) -> Decoder {
|
||||||
|
|
||||||
impl serialize::Decoder for Decoder {
|
impl serialize::Decoder for Decoder {
|
||||||
fn read_nil(&mut self) -> () {
|
fn read_nil(&mut self) -> () {
|
||||||
debug!("read_nil");
|
debug2!("read_nil");
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Null => (),
|
Null => (),
|
||||||
value => fail!("not a null: %?", value)
|
value => fail2!("not a null: {:?}", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,20 +905,20 @@ impl serialize::Decoder for Decoder {
|
||||||
fn read_int(&mut self) -> int { self.read_float() as int }
|
fn read_int(&mut self) -> int { self.read_float() as int }
|
||||||
|
|
||||||
fn read_bool(&mut self) -> bool {
|
fn read_bool(&mut self) -> bool {
|
||||||
debug!("read_bool");
|
debug2!("read_bool");
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Boolean(b) => b,
|
Boolean(b) => b,
|
||||||
value => fail!("not a boolean: %?", value)
|
value => fail2!("not a boolean: {:?}", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_f64(&mut self) -> f64 { self.read_float() as f64 }
|
fn read_f64(&mut self) -> f64 { self.read_float() as f64 }
|
||||||
fn read_f32(&mut self) -> f32 { self.read_float() as f32 }
|
fn read_f32(&mut self) -> f32 { self.read_float() as f32 }
|
||||||
fn read_float(&mut self) -> float {
|
fn read_float(&mut self) -> float {
|
||||||
debug!("read_float");
|
debug2!("read_float");
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Number(f) => f,
|
Number(f) => f,
|
||||||
value => fail!("not a number: %?", value)
|
value => fail2!("not a number: {:?}", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,20 +926,20 @@ impl serialize::Decoder for Decoder {
|
||||||
let mut v = ~[];
|
let mut v = ~[];
|
||||||
let s = self.read_str();
|
let s = self.read_str();
|
||||||
for c in s.iter() { v.push(c) }
|
for c in s.iter() { v.push(c) }
|
||||||
if v.len() != 1 { fail!("string must have one character") }
|
if v.len() != 1 { fail2!("string must have one character") }
|
||||||
v[0]
|
v[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_str(&mut self) -> ~str {
|
fn read_str(&mut self) -> ~str {
|
||||||
debug!("read_str");
|
debug2!("read_str");
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
String(s) => s,
|
String(s) => s,
|
||||||
json => fail!("not a string: %?", json)
|
json => fail2!("not a string: {:?}", json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T {
|
fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T {
|
||||||
debug!("read_enum(%s)", name);
|
debug2!("read_enum({})", name);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,13 +947,13 @@ impl serialize::Decoder for Decoder {
|
||||||
names: &[&str],
|
names: &[&str],
|
||||||
f: &fn(&mut Decoder, uint) -> T)
|
f: &fn(&mut Decoder, uint) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_variant(names=%?)", names);
|
debug2!("read_enum_variant(names={:?})", names);
|
||||||
let name = match self.stack.pop() {
|
let name = match self.stack.pop() {
|
||||||
String(s) => s,
|
String(s) => s,
|
||||||
Object(o) => {
|
Object(o) => {
|
||||||
let n = match o.find(&~"variant").expect("invalidly encoded json") {
|
let n = match o.find(&~"variant").expect("invalidly encoded json") {
|
||||||
&String(ref s) => s.clone(),
|
&String(ref s) => s.clone(),
|
||||||
_ => fail!("invalidly encoded json"),
|
_ => fail2!("invalidly encoded json"),
|
||||||
};
|
};
|
||||||
match o.find(&~"fields").expect("invalidly encoded json") {
|
match o.find(&~"fields").expect("invalidly encoded json") {
|
||||||
&List(ref l) => {
|
&List(ref l) => {
|
||||||
|
@ -961,15 +961,15 @@ impl serialize::Decoder for Decoder {
|
||||||
self.stack.push(field.clone());
|
self.stack.push(field.clone());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => fail!("invalidly encoded json")
|
_ => fail2!("invalidly encoded json")
|
||||||
}
|
}
|
||||||
n
|
n
|
||||||
}
|
}
|
||||||
ref json => fail!("invalid variant: %?", *json),
|
ref json => fail2!("invalid variant: {:?}", *json),
|
||||||
};
|
};
|
||||||
let idx = match names.iter().position(|n| str::eq_slice(*n, name)) {
|
let idx = match names.iter().position(|n| str::eq_slice(*n, name)) {
|
||||||
Some(idx) => idx,
|
Some(idx) => idx,
|
||||||
None => fail!("Unknown variant name: %?", name),
|
None => fail2!("Unknown variant name: {}", name),
|
||||||
};
|
};
|
||||||
f(self, idx)
|
f(self, idx)
|
||||||
}
|
}
|
||||||
|
@ -978,7 +978,7 @@ impl serialize::Decoder for Decoder {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_variant_arg(idx=%u)", idx);
|
debug2!("read_enum_variant_arg(idx={})", idx);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,7 +986,7 @@ impl serialize::Decoder for Decoder {
|
||||||
names: &[&str],
|
names: &[&str],
|
||||||
f: &fn(&mut Decoder, uint) -> T)
|
f: &fn(&mut Decoder, uint) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_struct_variant(names=%?)", names);
|
debug2!("read_enum_struct_variant(names={:?})", names);
|
||||||
self.read_enum_variant(names, f)
|
self.read_enum_variant(names, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +996,7 @@ impl serialize::Decoder for Decoder {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx);
|
debug2!("read_enum_struct_variant_field(name={}, idx={})", name, idx);
|
||||||
self.read_enum_variant_arg(idx, f)
|
self.read_enum_variant_arg(idx, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,7 +1005,7 @@ impl serialize::Decoder for Decoder {
|
||||||
len: uint,
|
len: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_struct(name=%s, len=%u)", name, len);
|
debug2!("read_struct(name={}, len={})", name, len);
|
||||||
let value = f(self);
|
let value = f(self);
|
||||||
self.stack.pop();
|
self.stack.pop();
|
||||||
value
|
value
|
||||||
|
@ -1016,12 +1016,12 @@ impl serialize::Decoder for Decoder {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_struct_field(name=%?, idx=%u)", name, idx);
|
debug2!("read_struct_field(name={}, idx={})", name, idx);
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Object(obj) => {
|
Object(obj) => {
|
||||||
let mut obj = obj;
|
let mut obj = obj;
|
||||||
let value = match obj.pop(&name.to_owned()) {
|
let value = match obj.pop(&name.to_owned()) {
|
||||||
None => fail!("no such field: %s", name),
|
None => fail2!("no such field: {}", name),
|
||||||
Some(json) => {
|
Some(json) => {
|
||||||
self.stack.push(json);
|
self.stack.push(json);
|
||||||
f(self)
|
f(self)
|
||||||
|
@ -1030,12 +1030,12 @@ impl serialize::Decoder for Decoder {
|
||||||
self.stack.push(Object(obj));
|
self.stack.push(Object(obj));
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
value => fail!("not an object: %?", value)
|
value => fail2!("not an object: {:?}", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
||||||
debug!("read_tuple()");
|
debug2!("read_tuple()");
|
||||||
self.read_seq(f)
|
self.read_seq(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,7 +1043,7 @@ impl serialize::Decoder for Decoder {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_tuple_arg(idx=%u)", idx);
|
debug2!("read_tuple_arg(idx={})", idx);
|
||||||
self.read_seq_elt(idx, f)
|
self.read_seq_elt(idx, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,7 +1051,7 @@ impl serialize::Decoder for Decoder {
|
||||||
name: &str,
|
name: &str,
|
||||||
f: &fn(&mut Decoder, uint) -> T)
|
f: &fn(&mut Decoder, uint) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_tuple_struct(name=%?)", name);
|
debug2!("read_tuple_struct(name={})", name);
|
||||||
self.read_tuple(f)
|
self.read_tuple(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,7 +1059,7 @@ impl serialize::Decoder for Decoder {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_tuple_struct_arg(idx=%u)", idx);
|
debug2!("read_tuple_struct_arg(idx={})", idx);
|
||||||
self.read_tuple_arg(idx, f)
|
self.read_tuple_arg(idx, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,7 +1071,7 @@ impl serialize::Decoder for Decoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
||||||
debug!("read_seq()");
|
debug2!("read_seq()");
|
||||||
let len = match self.stack.pop() {
|
let len = match self.stack.pop() {
|
||||||
List(list) => {
|
List(list) => {
|
||||||
let len = list.len();
|
let len = list.len();
|
||||||
|
@ -1080,18 +1080,18 @@ impl serialize::Decoder for Decoder {
|
||||||
}
|
}
|
||||||
len
|
len
|
||||||
}
|
}
|
||||||
_ => fail!("not a list"),
|
_ => fail2!("not a list"),
|
||||||
};
|
};
|
||||||
f(self, len)
|
f(self, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T {
|
fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T {
|
||||||
debug!("read_seq_elt(idx=%u)", idx);
|
debug2!("read_seq_elt(idx={})", idx);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
|
||||||
debug!("read_map()");
|
debug2!("read_map()");
|
||||||
let len = match self.stack.pop() {
|
let len = match self.stack.pop() {
|
||||||
Object(obj) => {
|
Object(obj) => {
|
||||||
let len = obj.len();
|
let len = obj.len();
|
||||||
|
@ -1101,7 +1101,7 @@ impl serialize::Decoder for Decoder {
|
||||||
}
|
}
|
||||||
len
|
len
|
||||||
}
|
}
|
||||||
json => fail!("not an object: %?", json),
|
json => fail2!("not an object: {:?}", json),
|
||||||
};
|
};
|
||||||
f(self, len)
|
f(self, len)
|
||||||
}
|
}
|
||||||
|
@ -1110,13 +1110,13 @@ impl serialize::Decoder for Decoder {
|
||||||
idx: uint,
|
idx: uint,
|
||||||
f: &fn(&mut Decoder) -> T)
|
f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_map_elt_key(idx=%u)", idx);
|
debug2!("read_map_elt_key(idx={})", idx);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
|
fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
|
||||||
-> T {
|
-> T {
|
||||||
debug!("read_map_elt_val(idx=%u)", idx);
|
debug2!("read_map_elt_val(idx={})", idx);
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1321,7 +1321,7 @@ impl to_str::ToStr for Json {
|
||||||
|
|
||||||
impl to_str::ToStr for Error {
|
impl to_str::ToStr for Error {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
fmt!("%u:%u: %s", self.line, self.col, *self.msg)
|
format!("{}:{}: {}", self.line, self.col, *self.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub fn len<T>(ls: @List<T>) -> uint {
|
||||||
pub fn tail<T>(ls: @List<T>) -> @List<T> {
|
pub fn tail<T>(ls: @List<T>) -> @List<T> {
|
||||||
match *ls {
|
match *ls {
|
||||||
Cons(_, tl) => return tl,
|
Cons(_, tl) => return tl,
|
||||||
Nil => fail!("list empty")
|
Nil => fail2!("list empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ pub fn head<T:Clone>(ls: @List<T>) -> T {
|
||||||
match *ls {
|
match *ls {
|
||||||
Cons(ref hd, _) => (*hd).clone(),
|
Cons(ref hd, _) => (*hd).clone(),
|
||||||
// makes me sad
|
// makes me sad
|
||||||
_ => fail!("head invoked on empty list")
|
_ => fail2!("head invoked on empty list")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ impl Rem<BigUint, BigUint> for BigUint {
|
||||||
|
|
||||||
impl Neg<BigUint> for BigUint {
|
impl Neg<BigUint> for BigUint {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn neg(&self) -> BigUint { fail!() }
|
fn neg(&self) -> BigUint { fail2!() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Integer for BigUint {
|
impl Integer for BigUint {
|
||||||
|
@ -374,7 +374,7 @@ impl Integer for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint) {
|
fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint) {
|
||||||
if other.is_zero() { fail!() }
|
if other.is_zero() { fail2!() }
|
||||||
if self.is_zero() { return (Zero::zero(), Zero::zero()); }
|
if self.is_zero() { return (Zero::zero(), Zero::zero()); }
|
||||||
if *other == One::one() { return ((*self).clone(), Zero::zero()); }
|
if *other == One::one() { return ((*self).clone(), Zero::zero()); }
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
|
||||||
14 => (1475789056, 8),
|
14 => (1475789056, 8),
|
||||||
15 => (2562890625, 8),
|
15 => (2562890625, 8),
|
||||||
16 => (4294967296, 8),
|
16 => (4294967296, 8),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +750,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
|
||||||
14 => (38416, 4),
|
14 => (38416, 4),
|
||||||
15 => (50625, 4),
|
15 => (50625, 4),
|
||||||
16 => (65536, 4),
|
16 => (65536, 4),
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,7 +1004,7 @@ impl Integer for BigInt {
|
||||||
let d = BigInt::from_biguint(Plus, d_ui);
|
let d = BigInt::from_biguint(Plus, d_ui);
|
||||||
let r = BigInt::from_biguint(Plus, r_ui);
|
let r = BigInt::from_biguint(Plus, r_ui);
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(_, Zero) => fail!(),
|
(_, Zero) => fail2!(),
|
||||||
(Plus, Plus) | (Zero, Plus) => ( d, r),
|
(Plus, Plus) | (Zero, Plus) => ( d, r),
|
||||||
(Plus, Minus) | (Zero, Minus) => (-d, r),
|
(Plus, Minus) | (Zero, Minus) => (-d, r),
|
||||||
(Minus, Plus) => (-d, -r),
|
(Minus, Plus) => (-d, -r),
|
||||||
|
@ -1030,7 +1030,7 @@ impl Integer for BigInt {
|
||||||
let d = BigInt::from_biguint(Plus, d_ui);
|
let d = BigInt::from_biguint(Plus, d_ui);
|
||||||
let m = BigInt::from_biguint(Plus, m_ui);
|
let m = BigInt::from_biguint(Plus, m_ui);
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(_, Zero) => fail!(),
|
(_, Zero) => fail2!(),
|
||||||
(Plus, Plus) | (Zero, Plus) => (d, m),
|
(Plus, Plus) | (Zero, Plus) => (d, m),
|
||||||
(Plus, Minus) | (Zero, Minus) => if m.is_zero() {
|
(Plus, Minus) | (Zero, Minus) => if m.is_zero() {
|
||||||
(-d, Zero::zero())
|
(-d, Zero::zero())
|
||||||
|
@ -1742,7 +1742,7 @@ mod biguint_tests {
|
||||||
~"2" +
|
~"2" +
|
||||||
str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"),
|
str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"),
|
||||||
(10, match bits {
|
(10, match bits {
|
||||||
32 => ~"8589934593", 16 => ~"131073", _ => fail!()
|
32 => ~"8589934593", 16 => ~"131073", _ => fail2!()
|
||||||
}),
|
}),
|
||||||
(16,
|
(16,
|
||||||
~"2" +
|
~"2" +
|
||||||
|
@ -1759,7 +1759,7 @@ mod biguint_tests {
|
||||||
(10, match bits {
|
(10, match bits {
|
||||||
32 => ~"55340232229718589441",
|
32 => ~"55340232229718589441",
|
||||||
16 => ~"12885032961",
|
16 => ~"12885032961",
|
||||||
_ => fail!()
|
_ => fail2!()
|
||||||
}),
|
}),
|
||||||
(16, ~"3" +
|
(16, ~"3" +
|
||||||
str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" +
|
str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" +
|
||||||
|
@ -1814,7 +1814,7 @@ mod biguint_tests {
|
||||||
fn check(n: uint, s: &str) {
|
fn check(n: uint, s: &str) {
|
||||||
let n = factor(n);
|
let n = factor(n);
|
||||||
let ans = match FromStrRadix::from_str_radix(s, 10) {
|
let ans = match FromStrRadix::from_str_radix(s, 10) {
|
||||||
Some(x) => x, None => fail!()
|
Some(x) => x, None => fail2!()
|
||||||
};
|
};
|
||||||
assert_eq!(n, ans);
|
assert_eq!(n, ans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,9 +172,9 @@ impl<T: Clone + Num> One for Cmplx<T> {
|
||||||
impl<T: ToStr + Num + Ord> ToStr for Cmplx<T> {
|
impl<T: ToStr + Num + Ord> ToStr for Cmplx<T> {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
if self.im < Zero::zero() {
|
if self.im < Zero::zero() {
|
||||||
fmt!("%s-%si", self.re.to_str(), (-self.im).to_str())
|
format!("{}-{}i", self.re.to_str(), (-self.im).to_str())
|
||||||
} else {
|
} else {
|
||||||
fmt!("%s+%si", self.re.to_str(), self.im.to_str())
|
format!("{}+{}i", self.re.to_str(), self.im.to_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,9 @@ impl<T: ToStr + Num + Ord> ToStr for Cmplx<T> {
|
||||||
impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {
|
impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {
|
||||||
fn to_str_radix(&self, radix: uint) -> ~str {
|
fn to_str_radix(&self, radix: uint) -> ~str {
|
||||||
if self.im < Zero::zero() {
|
if self.im < Zero::zero() {
|
||||||
fmt!("%s-%si", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix))
|
format!("{}-{}i", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix))
|
||||||
} else {
|
} else {
|
||||||
fmt!("%s+%si", self.re.to_str_radix(radix), self.im.to_str_radix(radix))
|
format!("{}+{}i", self.re.to_str_radix(radix), self.im.to_str_radix(radix))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl<T: Clone + Integer + Ord>
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(numer: T, denom: T) -> Ratio<T> {
|
pub fn new(numer: T, denom: T) -> Ratio<T> {
|
||||||
if denom == Zero::zero() {
|
if denom == Zero::zero() {
|
||||||
fail!("denominator == 0");
|
fail2!("denominator == 0");
|
||||||
}
|
}
|
||||||
let mut ret = Ratio::new_raw(numer, denom);
|
let mut ret = Ratio::new_raw(numer, denom);
|
||||||
ret.reduce();
|
ret.reduce();
|
||||||
|
@ -254,13 +254,13 @@ impl<T: Clone + Integer + Ord> Fractional for Ratio<T> {
|
||||||
impl<T: ToStr> ToStr for Ratio<T> {
|
impl<T: ToStr> ToStr for Ratio<T> {
|
||||||
/// Renders as `numer/denom`.
|
/// Renders as `numer/denom`.
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
fmt!("%s/%s", self.numer.to_str(), self.denom.to_str())
|
format!("{}/{}", self.numer.to_str(), self.denom.to_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
|
impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
|
||||||
/// Renders as `numer/denom` where the numbers are in base `radix`.
|
/// Renders as `numer/denom` where the numbers are in base `radix`.
|
||||||
fn to_str_radix(&self, radix: uint) -> ~str {
|
fn to_str_radix(&self, radix: uint) -> ~str {
|
||||||
fmt!("%s/%s", self.numer.to_str_radix(radix), self.denom.to_str_radix(radix))
|
format!("{}/{}", self.numer.to_str_radix(radix), self.denom.to_str_radix(radix))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl<T> RingBuf<T> {
|
||||||
pub fn get<'a>(&'a self, i: uint) -> &'a T {
|
pub fn get<'a>(&'a self, i: uint) -> &'a T {
|
||||||
let idx = self.raw_index(i);
|
let idx = self.raw_index(i);
|
||||||
match self.elts[idx] {
|
match self.elts[idx] {
|
||||||
None => fail!(),
|
None => fail2!(),
|
||||||
Some(ref v) => v
|
Some(ref v) => v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ impl<T> RingBuf<T> {
|
||||||
pub fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T {
|
pub fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T {
|
||||||
let idx = self.raw_index(i);
|
let idx = self.raw_index(i);
|
||||||
match self.elts[idx] {
|
match self.elts[idx] {
|
||||||
None => fail!(),
|
None => fail2!(),
|
||||||
Some(ref mut v) => v
|
Some(ref mut v) => v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,21 +373,21 @@ mod tests {
|
||||||
assert_eq!(d.len(), 3u);
|
assert_eq!(d.len(), 3u);
|
||||||
d.push_back(137);
|
d.push_back(137);
|
||||||
assert_eq!(d.len(), 4u);
|
assert_eq!(d.len(), 4u);
|
||||||
debug!(d.front());
|
debug2!("{:?}", d.front());
|
||||||
assert_eq!(*d.front().unwrap(), 42);
|
assert_eq!(*d.front().unwrap(), 42);
|
||||||
debug!(d.back());
|
debug2!("{:?}", d.back());
|
||||||
assert_eq!(*d.back().unwrap(), 137);
|
assert_eq!(*d.back().unwrap(), 137);
|
||||||
let mut i = d.pop_front();
|
let mut i = d.pop_front();
|
||||||
debug!(i);
|
debug2!("{:?}", i);
|
||||||
assert_eq!(i, Some(42));
|
assert_eq!(i, Some(42));
|
||||||
i = d.pop_back();
|
i = d.pop_back();
|
||||||
debug!(i);
|
debug2!("{:?}", i);
|
||||||
assert_eq!(i, Some(137));
|
assert_eq!(i, Some(137));
|
||||||
i = d.pop_back();
|
i = d.pop_back();
|
||||||
debug!(i);
|
debug2!("{:?}", i);
|
||||||
assert_eq!(i, Some(137));
|
assert_eq!(i, Some(137));
|
||||||
i = d.pop_back();
|
i = d.pop_back();
|
||||||
debug!(i);
|
debug2!("{:?}", i);
|
||||||
assert_eq!(i, Some(17));
|
assert_eq!(i, Some(17));
|
||||||
assert_eq!(d.len(), 0u);
|
assert_eq!(d.len(), 0u);
|
||||||
d.push_back(3);
|
d.push_back(3);
|
||||||
|
@ -398,10 +398,10 @@ mod tests {
|
||||||
assert_eq!(d.len(), 3u);
|
assert_eq!(d.len(), 3u);
|
||||||
d.push_front(1);
|
d.push_front(1);
|
||||||
assert_eq!(d.len(), 4u);
|
assert_eq!(d.len(), 4u);
|
||||||
debug!(d.get(0));
|
debug2!("{:?}", d.get(0));
|
||||||
debug!(d.get(1));
|
debug2!("{:?}", d.get(1));
|
||||||
debug!(d.get(2));
|
debug2!("{:?}", d.get(2));
|
||||||
debug!(d.get(3));
|
debug2!("{:?}", d.get(3));
|
||||||
assert_eq!(*d.get(0), 1);
|
assert_eq!(*d.get(0), 1);
|
||||||
assert_eq!(*d.get(1), 2);
|
assert_eq!(*d.get(1), 2);
|
||||||
assert_eq!(*d.get(2), 3);
|
assert_eq!(*d.get(2), 3);
|
||||||
|
|
|
@ -86,16 +86,16 @@ pub struct Version {
|
||||||
impl ToStr for Version {
|
impl ToStr for Version {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
let s = fmt!("%u.%u.%u", self.major, self.minor, self.patch);
|
let s = format!("{}.{}.{}", self.major, self.minor, self.patch);
|
||||||
let s = if self.pre.is_empty() {
|
let s = if self.pre.is_empty() {
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
fmt!("%s-%s", s, self.pre.map(|i| i.to_str()).connect("."))
|
format!("{}-{}", s, self.pre.map(|i| i.to_str()).connect("."))
|
||||||
};
|
};
|
||||||
if self.build.is_empty() {
|
if self.build.is_empty() {
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
fmt!("%s+%s", s, self.build.map(|i| i.to_str()).connect("."))
|
format!("{}+{}", s, self.build.map(|i| i.to_str()).connect("."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ fn take_nonempty_prefix(rdr: @io::Reader,
|
||||||
if buf.is_empty() {
|
if buf.is_empty() {
|
||||||
bad_parse::cond.raise(())
|
bad_parse::cond.raise(())
|
||||||
}
|
}
|
||||||
debug!("extracted nonempty prefix: %s", buf);
|
debug2!("extracted nonempty prefix: {}", buf);
|
||||||
(buf, ch)
|
(buf, ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ pub fn parse(s: &str) -> Option<Version> {
|
||||||
}
|
}
|
||||||
let s = s.trim();
|
let s = s.trim();
|
||||||
let mut bad = false;
|
let mut bad = false;
|
||||||
do bad_parse::cond.trap(|_| { debug!("bad"); bad = true }).inside {
|
do bad_parse::cond.trap(|_| { debug2!("bad"); bad = true }).inside {
|
||||||
do io::with_str_reader(s) |rdr| {
|
do io::with_str_reader(s) |rdr| {
|
||||||
let v = parse_reader(rdr);
|
let v = parse_reader(rdr);
|
||||||
if bad || v.to_str() != s.to_owned() {
|
if bad || v.to_str() != s.to_owned() {
|
||||||
|
|
|
@ -265,7 +265,7 @@ mod test_map {
|
||||||
assert!(m.insert(5, 14));
|
assert!(m.insert(5, 14));
|
||||||
let new = 100;
|
let new = 100;
|
||||||
match m.find_mut(&5) {
|
match m.find_mut(&5) {
|
||||||
None => fail!(), Some(x) => *x = new
|
None => fail2!(), Some(x) => *x = new
|
||||||
}
|
}
|
||||||
assert_eq!(m.find(&5), Some(&new));
|
assert_eq!(m.find(&5), Some(&new));
|
||||||
}
|
}
|
||||||
|
|
|
@ -564,7 +564,7 @@ impl<T:Clone + Ord> MergeState<T> {
|
||||||
shift_vec(array, dest, c2, len2);
|
shift_vec(array, dest, c2, len2);
|
||||||
swap(&mut array[dest+len2], &mut tmp[c1]);
|
swap(&mut array[dest+len2], &mut tmp[c1]);
|
||||||
} else if len1 == 0 {
|
} else if len1 == 0 {
|
||||||
fail!("Comparison violates its contract!");
|
fail2!("Comparison violates its contract!");
|
||||||
} else {
|
} else {
|
||||||
assert_eq!(len2, 0);
|
assert_eq!(len2, 0);
|
||||||
assert!(len1 > 1);
|
assert!(len1 > 1);
|
||||||
|
@ -683,7 +683,7 @@ impl<T:Clone + Ord> MergeState<T> {
|
||||||
shift_vec(array, dest+1, c1+1, len1);
|
shift_vec(array, dest+1, c1+1, len1);
|
||||||
swap(&mut array[dest], &mut tmp[c2]);
|
swap(&mut array[dest], &mut tmp[c2]);
|
||||||
} else if len2 == 0 {
|
} else if len2 == 0 {
|
||||||
fail!("Comparison violates its contract!");
|
fail2!("Comparison violates its contract!");
|
||||||
} else {
|
} else {
|
||||||
assert_eq!(len1, 0);
|
assert_eq!(len1, 0);
|
||||||
assert!(len2 != 0);
|
assert!(len2 != 0);
|
||||||
|
@ -790,7 +790,7 @@ mod test_qsort {
|
||||||
quick_sort::<int>(v1, leual);
|
quick_sort::<int>(v1, leual);
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < len {
|
while i < len {
|
||||||
// debug!(v2[i]);
|
// debug2!(v2[i]);
|
||||||
assert_eq!(v2[i], v1[i]);
|
assert_eq!(v2[i], v1[i]);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +833,7 @@ mod test_qsort {
|
||||||
let immut_names = names;
|
let immut_names = names;
|
||||||
|
|
||||||
for (&a, &b) in expected.iter().zip(immut_names.iter()) {
|
for (&a, &b) in expected.iter().zip(immut_names.iter()) {
|
||||||
debug!("%d %d", a, b);
|
debug2!("{} {}", a, b);
|
||||||
assert_eq!(a, b);
|
assert_eq!(a, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -851,7 +851,7 @@ mod tests {
|
||||||
let v3 = merge_sort::<int>(v1, f);
|
let v3 = merge_sort::<int>(v1, f);
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < len {
|
while i < len {
|
||||||
debug!(v3[i]);
|
debug2!("{:?}", v3[i]);
|
||||||
assert_eq!(v3[i], v2[i]);
|
assert_eq!(v3[i], v2[i]);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@ -922,7 +922,7 @@ mod test_tim_sort {
|
||||||
fn lt(&self, other: &CVal) -> bool {
|
fn lt(&self, other: &CVal) -> bool {
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::rng();
|
||||||
if rng.gen::<float>() > 0.995 {
|
if rng.gen::<float>() > 0.995 {
|
||||||
fail!("It's happening!!!");
|
fail2!("It's happening!!!");
|
||||||
}
|
}
|
||||||
(*self).val < other.val
|
(*self).val < other.val
|
||||||
}
|
}
|
||||||
|
@ -936,7 +936,7 @@ mod test_tim_sort {
|
||||||
tim_sort::<int>(v1);
|
tim_sort::<int>(v1);
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < len {
|
while i < len {
|
||||||
// debug!(v2[i]);
|
// debug2!(v2[i]);
|
||||||
assert_eq!(v2[i], v1[i]);
|
assert_eq!(v2[i], v1[i]);
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
|
@ -977,7 +977,7 @@ mod test_tim_sort {
|
||||||
};
|
};
|
||||||
|
|
||||||
tim_sort(arr);
|
tim_sort(arr);
|
||||||
fail!("Guarantee the fail");
|
fail2!("Guarantee the fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
|
@ -1045,7 +1045,7 @@ mod big_tests {
|
||||||
fn isSorted<T:Ord>(arr: &[T]) {
|
fn isSorted<T:Ord>(arr: &[T]) {
|
||||||
for i in range(0u, arr.len() - 1) {
|
for i in range(0u, arr.len() - 1) {
|
||||||
if arr[i] > arr[i+1] {
|
if arr[i] > arr[i+1] {
|
||||||
fail!("Array not sorted");
|
fail2!("Array not sorted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1116,7 +1116,7 @@ mod big_tests {
|
||||||
fn isSorted<T:Ord>(arr: &[@T]) {
|
fn isSorted<T:Ord>(arr: &[@T]) {
|
||||||
for i in range(0u, arr.len() - 1) {
|
for i in range(0u, arr.len() - 1) {
|
||||||
if arr[i] > arr[i+1] {
|
if arr[i] > arr[i+1] {
|
||||||
fail!("Array not sorted");
|
fail2!("Array not sorted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,12 +267,12 @@ pub fn winsorize(samples: &mut [f64], pct: f64) {
|
||||||
/// Render writes the min, max and quartiles of the provided `Summary` to the provided `Writer`.
|
/// Render writes the min, max and quartiles of the provided `Summary` to the provided `Writer`.
|
||||||
pub fn write_5_number_summary(w: @io::Writer, s: &Summary) {
|
pub fn write_5_number_summary(w: @io::Writer, s: &Summary) {
|
||||||
let (q1,q2,q3) = s.quartiles;
|
let (q1,q2,q3) = s.quartiles;
|
||||||
w.write_str(fmt!("(min=%f, q1=%f, med=%f, q3=%f, max=%f)",
|
w.write_str(format!("(min={}, q1={}, med={}, q3={}, max={})",
|
||||||
s.min as float,
|
s.min,
|
||||||
q1 as float,
|
q1,
|
||||||
q2 as float,
|
q2,
|
||||||
q3 as float,
|
q3,
|
||||||
s.max as float));
|
s.max));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render a boxplot to the provided writer. The boxplot shows the min, max and quartiles of the
|
/// Render a boxplot to the provided writer. The boxplot shows the min, max and quartiles of the
|
||||||
|
|
|
@ -307,9 +307,9 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
|
||||||
blk: &fn() -> U) -> U {
|
blk: &fn() -> U) -> U {
|
||||||
match out_of_bounds {
|
match out_of_bounds {
|
||||||
Some(0) =>
|
Some(0) =>
|
||||||
fail!("%s with illegal ID %u - this lock has no condvars!", act, id),
|
fail2!("{} with illegal ID {} - this lock has no condvars!", act, id),
|
||||||
Some(length) =>
|
Some(length) =>
|
||||||
fail!("%s with illegal ID %u - ID must be less than %u", act, id, length),
|
fail2!("{} with illegal ID {} - ID must be less than {}", act, id, length),
|
||||||
None => blk()
|
None => blk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +634,7 @@ impl RWLock {
|
||||||
pub fn downgrade<'a>(&self, token: RWLockWriteMode<'a>)
|
pub fn downgrade<'a>(&self, token: RWLockWriteMode<'a>)
|
||||||
-> RWLockReadMode<'a> {
|
-> RWLockReadMode<'a> {
|
||||||
if !borrow::ref_eq(self, token.lock) {
|
if !borrow::ref_eq(self, token.lock) {
|
||||||
fail!("Can't downgrade() with a different rwlock's write_mode!");
|
fail2!("Can't downgrade() with a different rwlock's write_mode!");
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
|
@ -918,7 +918,7 @@ mod tests {
|
||||||
|
|
||||||
let result: result::Result<(),()> = do task::try {
|
let result: result::Result<(),()> = do task::try {
|
||||||
do m2.lock {
|
do m2.lock {
|
||||||
fail!();
|
fail2!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
@ -938,7 +938,7 @@ mod tests {
|
||||||
do task::spawn || { // linked
|
do task::spawn || { // linked
|
||||||
let _ = p.recv(); // wait for sibling to get in the mutex
|
let _ = p.recv(); // wait for sibling to get in the mutex
|
||||||
task::deschedule();
|
task::deschedule();
|
||||||
fail!();
|
fail2!();
|
||||||
}
|
}
|
||||||
do m2.lock_cond |cond| {
|
do m2.lock_cond |cond| {
|
||||||
c.send(()); // tell sibling go ahead
|
c.send(()); // tell sibling go ahead
|
||||||
|
@ -976,9 +976,9 @@ mod tests {
|
||||||
do (|| {
|
do (|| {
|
||||||
cond.wait(); // block forever
|
cond.wait(); // block forever
|
||||||
}).finally {
|
}).finally {
|
||||||
error!("task unwinding and sending");
|
error2!("task unwinding and sending");
|
||||||
c.send(());
|
c.send(());
|
||||||
error!("task unwinding and done sending");
|
error2!("task unwinding and done sending");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,7 +988,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
do m2.lock { }
|
do m2.lock { }
|
||||||
c.send(sibling_convos); // let parent wait on all children
|
c.send(sibling_convos); // let parent wait on all children
|
||||||
fail!();
|
fail2!();
|
||||||
};
|
};
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
// child task must have finished by the time try returns
|
// child task must have finished by the time try returns
|
||||||
|
@ -1028,7 +1028,7 @@ mod tests {
|
||||||
let _ = p.recv();
|
let _ = p.recv();
|
||||||
do m.lock_cond |cond| {
|
do m.lock_cond |cond| {
|
||||||
if !cond.signal_on(0) {
|
if !cond.signal_on(0) {
|
||||||
fail!(); // success; punt sibling awake.
|
fail2!(); // success; punt sibling awake.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1272,7 +1272,7 @@ mod tests {
|
||||||
|
|
||||||
let result: result::Result<(),()> = do task::try || {
|
let result: result::Result<(),()> = do task::try || {
|
||||||
do lock_rwlock_in_mode(&x2, mode1) {
|
do lock_rwlock_in_mode(&x2, mode1) {
|
||||||
fail!();
|
fail2!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
@ -1319,7 +1319,7 @@ mod tests {
|
||||||
let mut xopt = Some(xwrite);
|
let mut xopt = Some(xwrite);
|
||||||
do y.write_downgrade |_ywrite| {
|
do y.write_downgrade |_ywrite| {
|
||||||
y.downgrade(xopt.take_unwrap());
|
y.downgrade(xopt.take_unwrap());
|
||||||
error!("oops, y.downgrade(x) should have failed!");
|
error2!("oops, y.downgrade(x) should have failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ impl Terminal {
|
||||||
self.out.write(s.unwrap());
|
self.out.write(s.unwrap());
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
warn!("%s", s.unwrap_err());
|
warn2!("{}", s.unwrap_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
@ -167,7 +167,7 @@ impl Terminal {
|
||||||
self.out.write(s.unwrap());
|
self.out.write(s.unwrap());
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
warn!("%s", s.unwrap_err());
|
warn2!("{}", s.unwrap_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
@ -188,7 +188,7 @@ impl Terminal {
|
||||||
self.out.write(s.unwrap());
|
self.out.write(s.unwrap());
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
warn!("%s", s.unwrap_err());
|
warn2!("{}", s.unwrap_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
@ -226,11 +226,11 @@ impl Terminal {
|
||||||
if s.is_ok() {
|
if s.is_ok() {
|
||||||
self.out.write(s.unwrap());
|
self.out.write(s.unwrap());
|
||||||
} else if self.num_colors > 0 {
|
} else if self.num_colors > 0 {
|
||||||
warn!("%s", s.unwrap_err());
|
warn2!("{}", s.unwrap_err());
|
||||||
} else {
|
} else {
|
||||||
// if we support attributes but not color, it would be nice to still warn!()
|
// if we support attributes but not color, it would be nice to still warn2!()
|
||||||
// but it's not worth testing all known attributes just for this.
|
// but it's not worth testing all known attributes just for this.
|
||||||
debug!("%s", s.unwrap_err());
|
debug2!("{}", s.unwrap_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
|
||||||
'e' => state = SeekIfEnd(0),
|
'e' => state = SeekIfEnd(0),
|
||||||
';' => (),
|
';' => (),
|
||||||
|
|
||||||
_ => return Err(fmt!("unrecognized format option %c", cur))
|
_ => return Err(format!("unrecognized format option {}", cur))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PushParam => {
|
PushParam => {
|
||||||
|
@ -461,7 +461,7 @@ impl FormatOp {
|
||||||
'x' => FormatHex,
|
'x' => FormatHex,
|
||||||
'X' => FormatHEX,
|
'X' => FormatHEX,
|
||||||
's' => FormatString,
|
's' => FormatString,
|
||||||
_ => fail!("bad FormatOp char")
|
_ => fail2!("bad FormatOp char")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn to_char(self) -> char {
|
fn to_char(self) -> char {
|
||||||
|
@ -551,7 +551,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(fmt!("non-string on stack with %%%c", op.to_char()))
|
return Err(format!("non-string on stack with %{}", op.to_char()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,23 +606,23 @@ mod test {
|
||||||
for cap in caps.iter() {
|
for cap in caps.iter() {
|
||||||
let res = expand(cap.as_bytes(), [], vars);
|
let res = expand(cap.as_bytes(), [], vars);
|
||||||
assert!(res.is_err(),
|
assert!(res.is_err(),
|
||||||
"Op %s succeeded incorrectly with 0 stack entries", *cap);
|
"Op {} succeeded incorrectly with 0 stack entries", *cap);
|
||||||
let p = if *cap == "%s" || *cap == "%l" { String(~"foo") } else { Number(97) };
|
let p = if *cap == "%s" || *cap == "%l" { String(~"foo") } else { Number(97) };
|
||||||
let res = expand((bytes!("%p1")).to_owned() + cap.as_bytes(), [p], vars);
|
let res = expand((bytes!("%p1")).to_owned() + cap.as_bytes(), [p], vars);
|
||||||
assert!(res.is_ok(),
|
assert!(res.is_ok(),
|
||||||
"Op %s failed with 1 stack entry: %s", *cap, res.unwrap_err());
|
"Op {} failed with 1 stack entry: {}", *cap, res.unwrap_err());
|
||||||
}
|
}
|
||||||
let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"];
|
let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"];
|
||||||
for cap in caps.iter() {
|
for cap in caps.iter() {
|
||||||
let res = expand(cap.as_bytes(), [], vars);
|
let res = expand(cap.as_bytes(), [], vars);
|
||||||
assert!(res.is_err(),
|
assert!(res.is_err(),
|
||||||
"Binop %s succeeded incorrectly with 0 stack entries", *cap);
|
"Binop {} succeeded incorrectly with 0 stack entries", *cap);
|
||||||
let res = expand((bytes!("%{1}")).to_owned() + cap.as_bytes(), [], vars);
|
let res = expand((bytes!("%{1}")).to_owned() + cap.as_bytes(), [], vars);
|
||||||
assert!(res.is_err(),
|
assert!(res.is_err(),
|
||||||
"Binop %s succeeded incorrectly with 1 stack entry", *cap);
|
"Binop {} succeeded incorrectly with 1 stack entry", *cap);
|
||||||
let res = expand((bytes!("%{1}%{2}")).to_owned() + cap.as_bytes(), [], vars);
|
let res = expand((bytes!("%{1}%{2}")).to_owned() + cap.as_bytes(), [], vars);
|
||||||
assert!(res.is_ok(),
|
assert!(res.is_ok(),
|
||||||
"Binop %s failed with 2 stack entries: %s", *cap, res.unwrap_err());
|
"Binop {} failed with 2 stack entries: {}", *cap, res.unwrap_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,15 +635,15 @@ mod test {
|
||||||
fn test_comparison_ops() {
|
fn test_comparison_ops() {
|
||||||
let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])];
|
let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])];
|
||||||
for &(op, bs) in v.iter() {
|
for &(op, bs) in v.iter() {
|
||||||
let s = fmt!("%%{1}%%{2}%%%c%%d", op);
|
let s = format!("%\\{1\\}%\\{2\\}%{}%d", op);
|
||||||
let res = expand(s.as_bytes(), [], &mut Variables::new());
|
let res = expand(s.as_bytes(), [], &mut Variables::new());
|
||||||
assert!(res.is_ok(), res.unwrap_err());
|
assert!(res.is_ok(), res.unwrap_err());
|
||||||
assert_eq!(res.unwrap(), ~['0' as u8 + bs[0]]);
|
assert_eq!(res.unwrap(), ~['0' as u8 + bs[0]]);
|
||||||
let s = fmt!("%%{1}%%{1}%%%c%%d", op);
|
let s = format!("%\\{1\\}%\\{1\\}%{}%d", op);
|
||||||
let res = expand(s.as_bytes(), [], &mut Variables::new());
|
let res = expand(s.as_bytes(), [], &mut Variables::new());
|
||||||
assert!(res.is_ok(), res.unwrap_err());
|
assert!(res.is_ok(), res.unwrap_err());
|
||||||
assert_eq!(res.unwrap(), ~['0' as u8 + bs[1]]);
|
assert_eq!(res.unwrap(), ~['0' as u8 + bs[1]]);
|
||||||
let s = fmt!("%%{2}%%{1}%%%c%%d", op);
|
let s = format!("%\\{2\\}%\\{1\\}%{}%d", op);
|
||||||
let res = expand(s.as_bytes(), [], &mut Variables::new());
|
let res = expand(s.as_bytes(), [], &mut Variables::new());
|
||||||
assert!(res.is_ok(), res.unwrap_err());
|
assert!(res.is_ok(), res.unwrap_err());
|
||||||
assert_eq!(res.unwrap(), ~['0' as u8 + bs[2]]);
|
assert_eq!(res.unwrap(), ~['0' as u8 + bs[2]]);
|
||||||
|
|
|
@ -178,7 +178,8 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
||||||
// Check magic number
|
// Check magic number
|
||||||
let magic = file.read_le_u16();
|
let magic = file.read_le_u16();
|
||||||
if (magic != 0x011A) {
|
if (magic != 0x011A) {
|
||||||
return Err(fmt!("invalid magic number: expected %x but found %x", 0x011A, magic as uint));
|
return Err(format!("invalid magic number: expected {:x} but found {:x}",
|
||||||
|
0x011A, magic as uint));
|
||||||
}
|
}
|
||||||
|
|
||||||
let names_bytes = file.read_le_i16() as int;
|
let names_bytes = file.read_le_i16() as int;
|
||||||
|
@ -189,26 +190,26 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
||||||
|
|
||||||
assert!(names_bytes > 0);
|
assert!(names_bytes > 0);
|
||||||
|
|
||||||
debug!("names_bytes = %?", names_bytes);
|
debug2!("names_bytes = {}", names_bytes);
|
||||||
debug!("bools_bytes = %?", bools_bytes);
|
debug2!("bools_bytes = {}", bools_bytes);
|
||||||
debug!("numbers_count = %?", numbers_count);
|
debug2!("numbers_count = {}", numbers_count);
|
||||||
debug!("string_offsets_count = %?", string_offsets_count);
|
debug2!("string_offsets_count = {}", string_offsets_count);
|
||||||
debug!("string_table_bytes = %?", string_table_bytes);
|
debug2!("string_table_bytes = {}", string_table_bytes);
|
||||||
|
|
||||||
if (bools_bytes as uint) > boolnames.len() {
|
if (bools_bytes as uint) > boolnames.len() {
|
||||||
error!("expected bools_bytes to be less than %? but found %?", boolnames.len(),
|
error2!("expected bools_bytes to be less than {} but found {}", boolnames.len(),
|
||||||
bools_bytes);
|
bools_bytes);
|
||||||
return Err(~"incompatible file: more booleans than expected");
|
return Err(~"incompatible file: more booleans than expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numbers_count as uint) > numnames.len() {
|
if (numbers_count as uint) > numnames.len() {
|
||||||
error!("expected numbers_count to be less than %? but found %?", numnames.len(),
|
error2!("expected numbers_count to be less than {} but found {}", numnames.len(),
|
||||||
numbers_count);
|
numbers_count);
|
||||||
return Err(~"incompatible file: more numbers than expected");
|
return Err(~"incompatible file: more numbers than expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string_offsets_count as uint) > stringnames.len() {
|
if (string_offsets_count as uint) > stringnames.len() {
|
||||||
error!("expected string_offsets_count to be less than %? but found %?", stringnames.len(),
|
error2!("expected string_offsets_count to be less than {} but found {}", stringnames.len(),
|
||||||
string_offsets_count);
|
string_offsets_count);
|
||||||
return Err(~"incompatible file: more string offsets than expected");
|
return Err(~"incompatible file: more string offsets than expected");
|
||||||
}
|
}
|
||||||
|
@ -218,26 +219,26 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
||||||
|
|
||||||
file.read_byte(); // consume NUL
|
file.read_byte(); // consume NUL
|
||||||
|
|
||||||
debug!("term names: %?", term_names);
|
debug2!("term names: {:?}", term_names);
|
||||||
|
|
||||||
let mut bools_map = HashMap::new();
|
let mut bools_map = HashMap::new();
|
||||||
if bools_bytes != 0 {
|
if bools_bytes != 0 {
|
||||||
for i in range(0, bools_bytes) {
|
for i in range(0, bools_bytes) {
|
||||||
let b = file.read_byte();
|
let b = file.read_byte();
|
||||||
if b < 0 {
|
if b < 0 {
|
||||||
error!("EOF reading bools after %? entries", i);
|
error2!("EOF reading bools after {} entries", i);
|
||||||
return Err(~"error: expected more bools but hit EOF");
|
return Err(~"error: expected more bools but hit EOF");
|
||||||
} else if b == 1 {
|
} else if b == 1 {
|
||||||
debug!("%s set", bnames[i]);
|
debug2!("{} set", bnames[i]);
|
||||||
bools_map.insert(bnames[i].to_owned(), true);
|
bools_map.insert(bnames[i].to_owned(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("bools: %?", bools_map);
|
debug2!("bools: {:?}", bools_map);
|
||||||
|
|
||||||
if (bools_bytes + names_bytes) % 2 == 1 {
|
if (bools_bytes + names_bytes) % 2 == 1 {
|
||||||
debug!("adjusting for padding between bools and numbers");
|
debug2!("adjusting for padding between bools and numbers");
|
||||||
file.read_byte(); // compensate for padding
|
file.read_byte(); // compensate for padding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,13 +247,13 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
||||||
for i in range(0, numbers_count) {
|
for i in range(0, numbers_count) {
|
||||||
let n = file.read_le_u16();
|
let n = file.read_le_u16();
|
||||||
if n != 0xFFFF {
|
if n != 0xFFFF {
|
||||||
debug!("%s#%?", nnames[i], n);
|
debug2!("{}\\#{}", nnames[i], n);
|
||||||
numbers_map.insert(nnames[i].to_owned(), n);
|
numbers_map.insert(nnames[i].to_owned(), n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("numbers: %?", numbers_map);
|
debug2!("numbers: {:?}", numbers_map);
|
||||||
|
|
||||||
let mut string_map = HashMap::new();
|
let mut string_map = HashMap::new();
|
||||||
|
|
||||||
|
@ -262,12 +263,12 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
||||||
string_offsets.push(file.read_le_u16());
|
string_offsets.push(file.read_le_u16());
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("offsets: %?", string_offsets);
|
debug2!("offsets: {:?}", string_offsets);
|
||||||
|
|
||||||
let string_table = file.read_bytes(string_table_bytes as uint);
|
let string_table = file.read_bytes(string_table_bytes as uint);
|
||||||
|
|
||||||
if string_table.len() != string_table_bytes as uint {
|
if string_table.len() != string_table_bytes as uint {
|
||||||
error!("EOF reading string table after %? bytes, wanted %?", string_table.len(),
|
error2!("EOF reading string table after {} bytes, wanted {}", string_table.len(),
|
||||||
string_table_bytes);
|
string_table_bytes);
|
||||||
return Err(~"error: hit EOF before end of string table");
|
return Err(~"error: hit EOF before end of string table");
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~path> {
|
||||||
return Some(newp);
|
return Some(newp);
|
||||||
}
|
}
|
||||||
// on some installations the dir is named after the hex of the char (e.g. OS X)
|
// on some installations the dir is named after the hex of the char (e.g. OS X)
|
||||||
let newp = ~p.push_many(&[fmt!("%x", first_char as uint), term.to_owned()]);
|
let newp = ~p.push_many(&[format!("{:x}", first_char as uint), term.to_owned()]);
|
||||||
if os::path_exists(p) && os::path_exists(newp) {
|
if os::path_exists(p) && os::path_exists(newp) {
|
||||||
return Some(newp);
|
return Some(newp);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~path> {
|
||||||
pub fn open(term: &str) -> Result<@Reader, ~str> {
|
pub fn open(term: &str) -> Result<@Reader, ~str> {
|
||||||
match get_dbpath_for_term(term) {
|
match get_dbpath_for_term(term) {
|
||||||
Some(x) => file_reader(x),
|
Some(x) => file_reader(x),
|
||||||
None => Err(fmt!("could not find terminfo entry for %s", term))
|
None => Err(format!("could not find terminfo entry for {}", term))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,10 +125,10 @@ pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) {
|
||||||
let opts =
|
let opts =
|
||||||
match parse_opts(args) {
|
match parse_opts(args) {
|
||||||
Some(Ok(o)) => o,
|
Some(Ok(o)) => o,
|
||||||
Some(Err(msg)) => fail!(msg),
|
Some(Err(msg)) => fail2!(msg),
|
||||||
None => return
|
None => return
|
||||||
};
|
};
|
||||||
if !run_tests_console(&opts, tests) { fail!("Some tests failed"); }
|
if !run_tests_console(&opts, tests) { fail2!("Some tests failed"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// A variant optimized for invocation with a static test vector.
|
// A variant optimized for invocation with a static test vector.
|
||||||
|
@ -148,7 +148,7 @@ pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) {
|
||||||
TestDescAndFn { testfn: StaticBenchFn(f), desc: t.desc.clone() },
|
TestDescAndFn { testfn: StaticBenchFn(f), desc: t.desc.clone() },
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
fail!("non-static tests passed to test::test_main_static");
|
fail2!("non-static tests passed to test::test_main_static");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -192,7 +192,7 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
|
||||||
fn usage(binary: &str, helpstr: &str) {
|
fn usage(binary: &str, helpstr: &str) {
|
||||||
#[fixed_stack_segment]; #[inline(never)];
|
#[fixed_stack_segment]; #[inline(never)];
|
||||||
|
|
||||||
let message = fmt!("Usage: %s [OPTIONS] [FILTER]", binary);
|
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
|
||||||
println(groups::usage(message, optgroups()));
|
println(groups::usage(message, optgroups()));
|
||||||
println("");
|
println("");
|
||||||
if helpstr == "help" {
|
if helpstr == "help" {
|
||||||
|
@ -210,7 +210,7 @@ Test Attributes:
|
||||||
#[bench] - Indicates a function is a benchmark to be run. This
|
#[bench] - Indicates a function is a benchmark to be run. This
|
||||||
function takes one argument (extra::test::BenchHarness).
|
function takes one argument (extra::test::BenchHarness).
|
||||||
#[should_fail] - This function (also labeled with #[test]) will only pass if
|
#[should_fail] - This function (also labeled with #[test]) will only pass if
|
||||||
the code causes a failure (an assertion failure or fail!)
|
the code causes a failure (an assertion failure or fail2!)
|
||||||
#[ignore] - When applied to a function which is already attributed as a
|
#[ignore] - When applied to a function which is already attributed as a
|
||||||
test, then the test runner will ignore these tests during
|
test, then the test runner will ignore these tests during
|
||||||
normal test runs. Running with --ignored will run these
|
normal test runs. Running with --ignored will run these
|
||||||
|
@ -327,7 +327,7 @@ impl ConsoleTestState {
|
||||||
io::Truncate]) {
|
io::Truncate]) {
|
||||||
result::Ok(w) => Some(w),
|
result::Ok(w) => Some(w),
|
||||||
result::Err(ref s) => {
|
result::Err(ref s) => {
|
||||||
fail!("can't open output file: %s", *s)
|
fail2!("can't open output file: {}", *s)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => None
|
None => None
|
||||||
|
@ -408,11 +408,11 @@ impl ConsoleTestState {
|
||||||
pub fn write_run_start(&mut self, len: uint) {
|
pub fn write_run_start(&mut self, len: uint) {
|
||||||
self.total = len;
|
self.total = len;
|
||||||
let noun = if len != 1 { &"tests" } else { &"test" };
|
let noun = if len != 1 { &"tests" } else { &"test" };
|
||||||
self.out.write_line(fmt!("\nrunning %u %s", len, noun));
|
self.out.write_line(format!("\nrunning {} {}", len, noun));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_test_start(&self, test: &TestDesc) {
|
pub fn write_test_start(&self, test: &TestDesc) {
|
||||||
self.out.write_str(fmt!("test %s ... ", test.name.to_str()));
|
self.out.write_str(format!("test {} ... ", test.name.to_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_result(&self, result: &TestResult) {
|
pub fn write_result(&self, result: &TestResult) {
|
||||||
|
@ -436,7 +436,7 @@ impl ConsoleTestState {
|
||||||
match self.log_out {
|
match self.log_out {
|
||||||
None => (),
|
None => (),
|
||||||
Some(out) => {
|
Some(out) => {
|
||||||
out.write_line(fmt!("%s %s",
|
out.write_line(format!("{} {}",
|
||||||
match *result {
|
match *result {
|
||||||
TrOk => ~"ok",
|
TrOk => ~"ok",
|
||||||
TrFailed => ~"failed",
|
TrFailed => ~"failed",
|
||||||
|
@ -456,7 +456,7 @@ impl ConsoleTestState {
|
||||||
}
|
}
|
||||||
sort::tim_sort(failures);
|
sort::tim_sort(failures);
|
||||||
for name in failures.iter() {
|
for name in failures.iter() {
|
||||||
self.out.write_line(fmt!(" %s", name.to_str()));
|
self.out.write_line(format!(" {}", name.to_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,31 +473,31 @@ impl ConsoleTestState {
|
||||||
MetricAdded => {
|
MetricAdded => {
|
||||||
added += 1;
|
added += 1;
|
||||||
self.write_added();
|
self.write_added();
|
||||||
self.out.write_line(fmt!(": %s", *k));
|
self.out.write_line(format!(": {}", *k));
|
||||||
}
|
}
|
||||||
MetricRemoved => {
|
MetricRemoved => {
|
||||||
removed += 1;
|
removed += 1;
|
||||||
self.write_removed();
|
self.write_removed();
|
||||||
self.out.write_line(fmt!(": %s", *k));
|
self.out.write_line(format!(": {}", *k));
|
||||||
}
|
}
|
||||||
Improvement(pct) => {
|
Improvement(pct) => {
|
||||||
improved += 1;
|
improved += 1;
|
||||||
self.out.write_str(*k);
|
self.out.write_str(*k);
|
||||||
self.out.write_str(": ");
|
self.out.write_str(": ");
|
||||||
self.write_improved();
|
self.write_improved();
|
||||||
self.out.write_line(fmt!(" by %.2f%%", pct as float))
|
self.out.write_line(format!(" by {:.2f}%", pct as float))
|
||||||
}
|
}
|
||||||
Regression(pct) => {
|
Regression(pct) => {
|
||||||
regressed += 1;
|
regressed += 1;
|
||||||
self.out.write_str(*k);
|
self.out.write_str(*k);
|
||||||
self.out.write_str(": ");
|
self.out.write_str(": ");
|
||||||
self.write_regressed();
|
self.write_regressed();
|
||||||
self.out.write_line(fmt!(" by %.2f%%", pct as float))
|
self.out.write_line(format!(" by {:.2f}%", pct as float))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.out.write_line(fmt!("result of ratchet: %u matrics added, %u removed, \
|
self.out.write_line(format!("result of ratchet: {} matrics added, {} removed, \
|
||||||
%u improved, %u regressed, %u noise",
|
{} improved, {} regressed, {} noise",
|
||||||
added, removed, improved, regressed, noise));
|
added, removed, improved, regressed, noise));
|
||||||
if regressed == 0 {
|
if regressed == 0 {
|
||||||
self.out.write_line("updated ratchet file")
|
self.out.write_line("updated ratchet file")
|
||||||
|
@ -514,11 +514,11 @@ impl ConsoleTestState {
|
||||||
let ratchet_success = match *ratchet_metrics {
|
let ratchet_success = match *ratchet_metrics {
|
||||||
None => true,
|
None => true,
|
||||||
Some(ref pth) => {
|
Some(ref pth) => {
|
||||||
self.out.write_str(fmt!("\nusing metrics ratchet: %s\n", pth.to_str()));
|
self.out.write_str(format!("\nusing metrics ratchet: {}\n", pth.to_str()));
|
||||||
match ratchet_pct {
|
match ratchet_pct {
|
||||||
None => (),
|
None => (),
|
||||||
Some(pct) =>
|
Some(pct) =>
|
||||||
self.out.write_str(fmt!("with noise-tolerance forced to: %f%%\n",
|
self.out.write_str(format!("with noise-tolerance forced to: {}%%\n",
|
||||||
pct as float))
|
pct as float))
|
||||||
}
|
}
|
||||||
let (diff, ok) = self.metrics.ratchet(pth, ratchet_pct);
|
let (diff, ok) = self.metrics.ratchet(pth, ratchet_pct);
|
||||||
|
@ -541,7 +541,7 @@ impl ConsoleTestState {
|
||||||
} else {
|
} else {
|
||||||
self.write_failed();
|
self.write_failed();
|
||||||
}
|
}
|
||||||
self.out.write_str(fmt!(". %u passed; %u failed; %u ignored; %u measured\n\n",
|
self.out.write_str(format!(". {} passed; {} failed; {} ignored; {} measured\n\n",
|
||||||
self.passed, self.failed, self.ignored, self.measured));
|
self.passed, self.failed, self.ignored, self.measured));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ impl ConsoleTestState {
|
||||||
|
|
||||||
pub fn fmt_metrics(mm: &MetricMap) -> ~str {
|
pub fn fmt_metrics(mm: &MetricMap) -> ~str {
|
||||||
let v : ~[~str] = mm.iter()
|
let v : ~[~str] = mm.iter()
|
||||||
.map(|(k,v)| fmt!("%s: %f (+/- %f)",
|
.map(|(k,v)| format!("{}: {} (+/- {})",
|
||||||
*k,
|
*k,
|
||||||
v.value as float,
|
v.value as float,
|
||||||
v.noise as float))
|
v.noise as float))
|
||||||
|
@ -559,12 +559,12 @@ pub fn fmt_metrics(mm: &MetricMap) -> ~str {
|
||||||
|
|
||||||
pub fn fmt_bench_samples(bs: &BenchSamples) -> ~str {
|
pub fn fmt_bench_samples(bs: &BenchSamples) -> ~str {
|
||||||
if bs.mb_s != 0 {
|
if bs.mb_s != 0 {
|
||||||
fmt!("%u ns/iter (+/- %u) = %u MB/s",
|
format!("{} ns/iter (+/- {}) = {} MB/s",
|
||||||
bs.ns_iter_summ.median as uint,
|
bs.ns_iter_summ.median as uint,
|
||||||
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint,
|
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint,
|
||||||
bs.mb_s)
|
bs.mb_s)
|
||||||
} else {
|
} else {
|
||||||
fmt!("%u ns/iter (+/- %u)",
|
format!("{} ns/iter (+/- {})",
|
||||||
bs.ns_iter_summ.median as uint,
|
bs.ns_iter_summ.median as uint,
|
||||||
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint)
|
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint)
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ pub fn fmt_bench_samples(bs: &BenchSamples) -> ~str {
|
||||||
pub fn run_tests_console(opts: &TestOpts,
|
pub fn run_tests_console(opts: &TestOpts,
|
||||||
tests: ~[TestDescAndFn]) -> bool {
|
tests: ~[TestDescAndFn]) -> bool {
|
||||||
fn callback(event: &TestEvent, st: &mut ConsoleTestState) {
|
fn callback(event: &TestEvent, st: &mut ConsoleTestState) {
|
||||||
debug!("callback(event=%?)", event);
|
debug2!("callback(event={:?})", event);
|
||||||
match (*event).clone() {
|
match (*event).clone() {
|
||||||
TeFiltered(ref filtered_tests) => st.write_run_start(filtered_tests.len()),
|
TeFiltered(ref filtered_tests) => st.write_run_start(filtered_tests.len()),
|
||||||
TeWait(ref test) => st.write_test_start(test),
|
TeWait(ref test) => st.write_test_start(test),
|
||||||
|
@ -612,7 +612,7 @@ pub fn run_tests_console(opts: &TestOpts,
|
||||||
None => (),
|
None => (),
|
||||||
Some(ref pth) => {
|
Some(ref pth) => {
|
||||||
st.metrics.save(pth);
|
st.metrics.save(pth);
|
||||||
st.out.write_str(fmt!("\nmetrics saved to: %s", pth.to_str()));
|
st.out.write_str(format!("\nmetrics saved to: {}", pth.to_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return st.write_run_finish(&opts.ratchet_metrics, opts.ratchet_noise_percent);
|
return st.write_run_finish(&opts.ratchet_metrics, opts.ratchet_noise_percent);
|
||||||
|
@ -688,7 +688,7 @@ fn run_tests(opts: &TestOpts,
|
||||||
// It's tempting to just spawn all the tests at once, but since we have
|
// It's tempting to just spawn all the tests at once, but since we have
|
||||||
// many tests that run in other processes we would be making a big mess.
|
// many tests that run in other processes we would be making a big mess.
|
||||||
let concurrency = get_concurrency();
|
let concurrency = get_concurrency();
|
||||||
debug!("using %u test tasks", concurrency);
|
debug2!("using {} test tasks", concurrency);
|
||||||
|
|
||||||
let mut remaining = filtered_tests;
|
let mut remaining = filtered_tests;
|
||||||
remaining.reverse();
|
remaining.reverse();
|
||||||
|
@ -735,7 +735,7 @@ fn get_concurrency() -> uint {
|
||||||
let opt_n: Option<uint> = FromStr::from_str(s);
|
let opt_n: Option<uint> = FromStr::from_str(s);
|
||||||
match opt_n {
|
match opt_n {
|
||||||
Some(n) if n > 0 => n,
|
Some(n) if n > 0 => n,
|
||||||
_ => fail!("RUST_TEST_TASKS is `%s`, should be a positive integer.", s)
|
_ => fail2!("RUST_TEST_TASKS is `{}`, should be a positive integer.", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -1001,7 +1001,7 @@ impl MetricMap {
|
||||||
};
|
};
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
debug!("rewriting file '%s' with updated metrics");
|
debug2!("rewriting file '{:?}' with updated metrics", p);
|
||||||
self.save(p);
|
self.save(p);
|
||||||
}
|
}
|
||||||
return (diff, ok)
|
return (diff, ok)
|
||||||
|
@ -1040,7 +1040,7 @@ impl BenchHarness {
|
||||||
|
|
||||||
pub fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) {
|
pub fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) {
|
||||||
self.iterations = n;
|
self.iterations = n;
|
||||||
debug!("running benchmark for %u iterations",
|
debug2!("running benchmark for {} iterations",
|
||||||
n as uint);
|
n as uint);
|
||||||
f(self);
|
f(self);
|
||||||
}
|
}
|
||||||
|
@ -1081,7 +1081,7 @@ impl BenchHarness {
|
||||||
stats::winsorize(samples, 5.0);
|
stats::winsorize(samples, 5.0);
|
||||||
let summ5 = stats::Summary::new(samples);
|
let summ5 = stats::Summary::new(samples);
|
||||||
|
|
||||||
debug!("%u samples, median %f, MAD=%f, MADP=%f",
|
debug2!("{} samples, median {}, MAD={}, MADP={}",
|
||||||
samples.len(),
|
samples.len(),
|
||||||
summ.median as float,
|
summ.median as float,
|
||||||
summ.median_abs_dev as float,
|
summ.median_abs_dev as float,
|
||||||
|
@ -1153,7 +1153,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn do_not_run_ignored_tests() {
|
pub fn do_not_run_ignored_tests() {
|
||||||
fn f() { fail!(); }
|
fn f() { fail2!(); }
|
||||||
let desc = TestDescAndFn {
|
let desc = TestDescAndFn {
|
||||||
desc: TestDesc {
|
desc: TestDesc {
|
||||||
name: StaticTestName("whatever"),
|
name: StaticTestName("whatever"),
|
||||||
|
@ -1189,7 +1189,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_should_fail() {
|
fn test_should_fail() {
|
||||||
fn f() { fail!(); }
|
fn f() { fail2!(); }
|
||||||
let desc = TestDescAndFn {
|
let desc = TestDescAndFn {
|
||||||
desc: TestDesc {
|
desc: TestDesc {
|
||||||
name: StaticTestName("whatever"),
|
name: StaticTestName("whatever"),
|
||||||
|
@ -1228,7 +1228,7 @@ mod tests {
|
||||||
let args = ~[~"progname", ~"filter"];
|
let args = ~[~"progname", ~"filter"];
|
||||||
let opts = match parse_opts(args) {
|
let opts = match parse_opts(args) {
|
||||||
Some(Ok(o)) => o,
|
Some(Ok(o)) => o,
|
||||||
_ => fail!("Malformed arg in first_free_arg_should_be_a_filter")
|
_ => fail2!("Malformed arg in first_free_arg_should_be_a_filter")
|
||||||
};
|
};
|
||||||
assert!("filter" == opts.filter.clone().unwrap());
|
assert!("filter" == opts.filter.clone().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1238,7 @@ mod tests {
|
||||||
let args = ~[~"progname", ~"filter", ~"--ignored"];
|
let args = ~[~"progname", ~"filter", ~"--ignored"];
|
||||||
let opts = match parse_opts(args) {
|
let opts = match parse_opts(args) {
|
||||||
Some(Ok(o)) => o,
|
Some(Ok(o)) => o,
|
||||||
_ => fail!("Malformed arg in parse_ignored_flag")
|
_ => fail2!("Malformed arg in parse_ignored_flag")
|
||||||
};
|
};
|
||||||
assert!((opts.run_ignored));
|
assert!((opts.run_ignored));
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl Tm {
|
||||||
let mut m = num::abs(self.tm_gmtoff) / 60_i32;
|
let mut m = num::abs(self.tm_gmtoff) / 60_i32;
|
||||||
let h = m / 60_i32;
|
let h = m / 60_i32;
|
||||||
m -= h * 60_i32;
|
m -= h * 60_i32;
|
||||||
s + fmt!("%c%02d:%02d", sign, h as int, m as int)
|
s + format!("{}{:02d}:{:02d}", sign, h as int, m as int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
|
||||||
if c == range.ch {
|
if c == range.ch {
|
||||||
Ok(range.next)
|
Ok(range.next)
|
||||||
} else {
|
} else {
|
||||||
Err(fmt!("Expected %?, found %?",
|
Err(format!("Expected {}, found {}",
|
||||||
str::from_char(c),
|
str::from_char(c),
|
||||||
str::from_char(range.ch)))
|
str::from_char(range.ch)))
|
||||||
}
|
}
|
||||||
|
@ -671,7 +671,7 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
|
||||||
}
|
}
|
||||||
'%' => parse_char(s, pos, '%'),
|
'%' => parse_char(s, pos, '%'),
|
||||||
ch => {
|
ch => {
|
||||||
Err(fmt!("unknown formatting type: %?", str::from_char(ch)))
|
Err(format!("unknown formatting type: {}", str::from_char(ch)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,7 +736,7 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
|
||||||
fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
||||||
fn parse_type(ch: char, tm: &Tm) -> ~str {
|
fn parse_type(ch: char, tm: &Tm) -> ~str {
|
||||||
//FIXME (#2350): Implement missing types.
|
//FIXME (#2350): Implement missing types.
|
||||||
let die = || fmt!("strftime: can't understand this format %c ", ch);
|
let die = || format!("strftime: can't understand this format {} ", ch);
|
||||||
match ch {
|
match ch {
|
||||||
'A' => match tm.tm_wday as int {
|
'A' => match tm.tm_wday as int {
|
||||||
0 => ~"Sunday",
|
0 => ~"Sunday",
|
||||||
|
@ -788,9 +788,9 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
||||||
11 => ~"Dec",
|
11 => ~"Dec",
|
||||||
_ => die()
|
_ => die()
|
||||||
},
|
},
|
||||||
'C' => fmt!("%02d", (tm.tm_year as int + 1900) / 100),
|
'C' => format!("{:02d}", (tm.tm_year as int + 1900) / 100),
|
||||||
'c' => {
|
'c' => {
|
||||||
fmt!("%s %s %s %s %s",
|
format!("{} {} {} {} {}",
|
||||||
parse_type('a', tm),
|
parse_type('a', tm),
|
||||||
parse_type('b', tm),
|
parse_type('b', tm),
|
||||||
parse_type('e', tm),
|
parse_type('e', tm),
|
||||||
|
@ -798,58 +798,58 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
||||||
parse_type('Y', tm))
|
parse_type('Y', tm))
|
||||||
}
|
}
|
||||||
'D' | 'x' => {
|
'D' | 'x' => {
|
||||||
fmt!("%s/%s/%s",
|
format!("{}/{}/{}",
|
||||||
parse_type('m', tm),
|
parse_type('m', tm),
|
||||||
parse_type('d', tm),
|
parse_type('d', tm),
|
||||||
parse_type('y', tm))
|
parse_type('y', tm))
|
||||||
}
|
}
|
||||||
'd' => fmt!("%02d", tm.tm_mday as int),
|
'd' => format!("{:02d}", tm.tm_mday),
|
||||||
'e' => fmt!("%2d", tm.tm_mday as int),
|
'e' => format!("{:2d}", tm.tm_mday),
|
||||||
'f' => fmt!("%09d", tm.tm_nsec as int),
|
'f' => format!("{:09d}", tm.tm_nsec),
|
||||||
'F' => {
|
'F' => {
|
||||||
fmt!("%s-%s-%s",
|
format!("{}-{}-{}",
|
||||||
parse_type('Y', tm),
|
parse_type('Y', tm),
|
||||||
parse_type('m', tm),
|
parse_type('m', tm),
|
||||||
parse_type('d', tm))
|
parse_type('d', tm))
|
||||||
}
|
}
|
||||||
//'G' {}
|
//'G' {}
|
||||||
//'g' {}
|
//'g' {}
|
||||||
'H' => fmt!("%02d", tm.tm_hour as int),
|
'H' => format!("{:02d}", tm.tm_hour),
|
||||||
'I' => {
|
'I' => {
|
||||||
let mut h = tm.tm_hour as int;
|
let mut h = tm.tm_hour;
|
||||||
if h == 0 { h = 12 }
|
if h == 0 { h = 12 }
|
||||||
if h > 12 { h -= 12 }
|
if h > 12 { h -= 12 }
|
||||||
fmt!("%02d", h)
|
format!("{:02d}", h)
|
||||||
}
|
}
|
||||||
'j' => fmt!("%03d", tm.tm_yday as int + 1),
|
'j' => format!("{:03d}", tm.tm_yday + 1),
|
||||||
'k' => fmt!("%2d", tm.tm_hour as int),
|
'k' => format!("{:2d}", tm.tm_hour),
|
||||||
'l' => {
|
'l' => {
|
||||||
let mut h = tm.tm_hour as int;
|
let mut h = tm.tm_hour;
|
||||||
if h == 0 { h = 12 }
|
if h == 0 { h = 12 }
|
||||||
if h > 12 { h -= 12 }
|
if h > 12 { h -= 12 }
|
||||||
fmt!("%2d", h)
|
format!("{:2d}", h)
|
||||||
}
|
}
|
||||||
'M' => fmt!("%02d", tm.tm_min as int),
|
'M' => format!("{:02d}", tm.tm_min),
|
||||||
'm' => fmt!("%02d", tm.tm_mon as int + 1),
|
'm' => format!("{:02d}", tm.tm_mon + 1),
|
||||||
'n' => ~"\n",
|
'n' => ~"\n",
|
||||||
'P' => if (tm.tm_hour as int) < 12 { ~"am" } else { ~"pm" },
|
'P' => if (tm.tm_hour as int) < 12 { ~"am" } else { ~"pm" },
|
||||||
'p' => if (tm.tm_hour as int) < 12 { ~"AM" } else { ~"PM" },
|
'p' => if (tm.tm_hour as int) < 12 { ~"AM" } else { ~"PM" },
|
||||||
'R' => {
|
'R' => {
|
||||||
fmt!("%s:%s",
|
format!("{}:{}",
|
||||||
parse_type('H', tm),
|
parse_type('H', tm),
|
||||||
parse_type('M', tm))
|
parse_type('M', tm))
|
||||||
}
|
}
|
||||||
'r' => {
|
'r' => {
|
||||||
fmt!("%s:%s:%s %s",
|
format!("{}:{}:{} {}",
|
||||||
parse_type('I', tm),
|
parse_type('I', tm),
|
||||||
parse_type('M', tm),
|
parse_type('M', tm),
|
||||||
parse_type('S', tm),
|
parse_type('S', tm),
|
||||||
parse_type('p', tm))
|
parse_type('p', tm))
|
||||||
}
|
}
|
||||||
'S' => fmt!("%02d", tm.tm_sec as int),
|
'S' => format!("{:02d}", tm.tm_sec),
|
||||||
's' => fmt!("%d", tm.to_timespec().sec as int),
|
's' => format!("{}", tm.to_timespec().sec),
|
||||||
'T' | 'X' => {
|
'T' | 'X' => {
|
||||||
fmt!("%s:%s:%s",
|
format!("{}:{}:{}",
|
||||||
parse_type('H', tm),
|
parse_type('H', tm),
|
||||||
parse_type('M', tm),
|
parse_type('M', tm),
|
||||||
parse_type('S', tm))
|
parse_type('S', tm))
|
||||||
|
@ -862,7 +862,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
||||||
}
|
}
|
||||||
//'V' {}
|
//'V' {}
|
||||||
'v' => {
|
'v' => {
|
||||||
fmt!("%s-%s-%s",
|
format!("{}-{}-{}",
|
||||||
parse_type('e', tm),
|
parse_type('e', tm),
|
||||||
parse_type('b', tm),
|
parse_type('b', tm),
|
||||||
parse_type('Y', tm))
|
parse_type('Y', tm))
|
||||||
|
@ -872,14 +872,14 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
||||||
//'X' {}
|
//'X' {}
|
||||||
//'x' {}
|
//'x' {}
|
||||||
'Y' => (tm.tm_year as int + 1900).to_str(),
|
'Y' => (tm.tm_year as int + 1900).to_str(),
|
||||||
'y' => fmt!("%02d", (tm.tm_year as int + 1900) % 100),
|
'y' => format!("{:02d}", (tm.tm_year as int + 1900) % 100),
|
||||||
'Z' => tm.tm_zone.clone(),
|
'Z' => tm.tm_zone.clone(),
|
||||||
'z' => {
|
'z' => {
|
||||||
let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
|
let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
|
||||||
let mut m = num::abs(tm.tm_gmtoff) / 60_i32;
|
let mut m = num::abs(tm.tm_gmtoff) / 60_i32;
|
||||||
let h = m / 60_i32;
|
let h = m / 60_i32;
|
||||||
m -= h * 60_i32;
|
m -= h * 60_i32;
|
||||||
fmt!("%c%02d%02d", sign, h as int, m as int)
|
format!("{}{:02d}{:02d}", sign, h, m)
|
||||||
}
|
}
|
||||||
//'+' {}
|
//'+' {}
|
||||||
'%' => ~"%",
|
'%' => ~"%",
|
||||||
|
@ -914,13 +914,13 @@ mod tests {
|
||||||
static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
|
static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
|
||||||
|
|
||||||
let tv1 = get_time();
|
let tv1 = get_time();
|
||||||
debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint);
|
debug2!("tv1={:?} sec + {:?} nsec", tv1.sec as uint, tv1.nsec as uint);
|
||||||
|
|
||||||
assert!(tv1.sec > SOME_RECENT_DATE);
|
assert!(tv1.sec > SOME_RECENT_DATE);
|
||||||
assert!(tv1.nsec < 1000000000i32);
|
assert!(tv1.nsec < 1000000000i32);
|
||||||
|
|
||||||
let tv2 = get_time();
|
let tv2 = get_time();
|
||||||
debug!("tv2=%? sec + %? nsec", tv2.sec as uint, tv2.nsec as uint);
|
debug2!("tv2={:?} sec + {:?} nsec", tv2.sec as uint, tv2.nsec as uint);
|
||||||
|
|
||||||
assert!(tv2.sec >= tv1.sec);
|
assert!(tv2.sec >= tv1.sec);
|
||||||
assert!(tv2.sec < SOME_FUTURE_DATE);
|
assert!(tv2.sec < SOME_FUTURE_DATE);
|
||||||
|
@ -934,16 +934,16 @@ mod tests {
|
||||||
let s0 = precise_time_s();
|
let s0 = precise_time_s();
|
||||||
let ns1 = precise_time_ns();
|
let ns1 = precise_time_ns();
|
||||||
|
|
||||||
debug!("s0=%s sec", float::to_str_digits(s0, 9u));
|
debug2!("s0={} sec", float::to_str_digits(s0, 9u));
|
||||||
assert!(s0 > 0.);
|
assert!(s0 > 0.);
|
||||||
let ns0 = (s0 * 1000000000.) as u64;
|
let ns0 = (s0 * 1000000000.) as u64;
|
||||||
debug!("ns0=%? ns", ns0);
|
debug2!("ns0={:?} ns", ns0);
|
||||||
|
|
||||||
debug!("ns1=%? ns", ns0);
|
debug2!("ns1={:?} ns", ns0);
|
||||||
assert!(ns1 >= ns0);
|
assert!(ns1 >= ns0);
|
||||||
|
|
||||||
let ns2 = precise_time_ns();
|
let ns2 = precise_time_ns();
|
||||||
debug!("ns2=%? ns", ns0);
|
debug2!("ns2={:?} ns", ns0);
|
||||||
assert!(ns2 >= ns1);
|
assert!(ns2 >= ns1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,7 +975,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);
|
error2!("time_at: {:?}", local);
|
||||||
|
|
||||||
assert!(local.tm_sec == 30_i32);
|
assert!(local.tm_sec == 30_i32);
|
||||||
assert!(local.tm_min == 31_i32);
|
assert!(local.tm_min == 31_i32);
|
||||||
|
@ -1050,7 +1050,7 @@ mod tests {
|
||||||
== Err(~"Invalid time"));
|
== Err(~"Invalid time"));
|
||||||
|
|
||||||
match strptime("Fri Feb 13 15:31:30.01234 2009", format) {
|
match strptime("Fri Feb 13 15:31:30.01234 2009", format) {
|
||||||
Err(e) => fail!(e),
|
Err(e) => fail2!(e),
|
||||||
Ok(ref tm) => {
|
Ok(ref tm) => {
|
||||||
assert!(tm.tm_sec == 30_i32);
|
assert!(tm.tm_sec == 30_i32);
|
||||||
assert!(tm.tm_min == 31_i32);
|
assert!(tm.tm_min == 31_i32);
|
||||||
|
@ -1070,7 +1070,7 @@ mod tests {
|
||||||
fn test(s: &str, format: &str) -> bool {
|
fn test(s: &str, format: &str) -> bool {
|
||||||
match strptime(s, format) {
|
match strptime(s, format) {
|
||||||
Ok(ref tm) => tm.strftime(format) == s.to_owned(),
|
Ok(ref tm) => tm.strftime(format) == s.to_owned(),
|
||||||
Err(e) => fail!(e)
|
Err(e) => fail2!(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,7 +1196,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());
|
error2!("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");
|
||||||
|
|
|
@ -831,7 +831,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return match node.take() {
|
return match node.take() {
|
||||||
Some(~TreeNode{value, _}) => Some(value), None => fail!()
|
Some(~TreeNode{value, _}) => Some(value), None => fail2!()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +900,7 @@ mod test_treemap {
|
||||||
assert!(m.insert(5, 14));
|
assert!(m.insert(5, 14));
|
||||||
let new = 100;
|
let new = 100;
|
||||||
match m.find_mut(&5) {
|
match m.find_mut(&5) {
|
||||||
None => fail!(), Some(x) => *x = new
|
None => fail2!(), Some(x) => *x = new
|
||||||
}
|
}
|
||||||
assert_eq!(m.find(&5), Some(&new));
|
assert_eq!(m.find(&5), Some(&new));
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,10 @@ fn encode_inner(s: &str, full_url: bool) -> ~str {
|
||||||
out.push_char(ch);
|
out.push_char(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => out.push_str(fmt!("%%%X", ch as uint))
|
_ => out.push_str(format!("%{:X}", ch as uint))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out.push_str(fmt!("%%%X", ch as uint));
|
out.push_str(format!("%{:X}", ch as uint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ fn encode_plus(s: &str) -> ~str {
|
||||||
out.push_char(ch);
|
out.push_char(ch);
|
||||||
}
|
}
|
||||||
' ' => out.push_char('+'),
|
' ' => out.push_char('+'),
|
||||||
_ => out.push_str(fmt!("%%%X", ch as uint))
|
_ => out.push_str(format!("%{:X}", ch as uint))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ pub fn encode_form_urlencoded(m: &HashMap<~str, ~[~str]>) -> ~str {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.push_str(fmt!("%s=%s", key, encode_plus(*value)));
|
out.push_str(format!("{}={}", key, encode_plus(*value)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,8 +324,8 @@ fn userinfo_from_str(uinfo: &str) -> UserInfo {
|
||||||
|
|
||||||
fn userinfo_to_str(userinfo: &UserInfo) -> ~str {
|
fn userinfo_to_str(userinfo: &UserInfo) -> ~str {
|
||||||
match userinfo.pass {
|
match userinfo.pass {
|
||||||
Some(ref pass) => fmt!("%s:%s@", userinfo.user, *pass),
|
Some(ref pass) => format!("{}:{}@", userinfo.user, *pass),
|
||||||
None => fmt!("%s@", userinfo.user),
|
None => format!("{}@", userinfo.user),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ pub fn query_to_str(query: &Query) -> ~str {
|
||||||
for kv in query.iter() {
|
for kv in query.iter() {
|
||||||
match kv {
|
match kv {
|
||||||
&(ref k, ref v) => {
|
&(ref k, ref v) => {
|
||||||
strvec.push(fmt!("%s=%s",
|
strvec.push(format!("{}={}",
|
||||||
encode_component(*k),
|
encode_component(*k),
|
||||||
encode_component(*v))
|
encode_component(*v))
|
||||||
);
|
);
|
||||||
|
@ -673,21 +673,21 @@ pub fn to_str(url: &Url) -> ~str {
|
||||||
let authority = if url.host.is_empty() {
|
let authority = if url.host.is_empty() {
|
||||||
~""
|
~""
|
||||||
} else {
|
} else {
|
||||||
fmt!("//%s%s", user, url.host)
|
format!("//{}{}", user, url.host)
|
||||||
};
|
};
|
||||||
|
|
||||||
let query = if url.query.is_empty() {
|
let query = if url.query.is_empty() {
|
||||||
~""
|
~""
|
||||||
} else {
|
} else {
|
||||||
fmt!("?%s", query_to_str(&url.query))
|
format!("?{}", query_to_str(&url.query))
|
||||||
};
|
};
|
||||||
|
|
||||||
let fragment = match url.fragment {
|
let fragment = match url.fragment {
|
||||||
Some(ref fragment) => fmt!("#%s", encode_component(*fragment)),
|
Some(ref fragment) => format!("\\#{}", encode_component(*fragment)),
|
||||||
None => ~"",
|
None => ~"",
|
||||||
};
|
};
|
||||||
|
|
||||||
fmt!("%s:%s%s%s%s", url.scheme, authority, url.path, query, fragment)
|
format!("{}:{}{}{}{}", url.scheme, authority, url.path, query, fragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStr for Url {
|
impl ToStr for Url {
|
||||||
|
|
|
@ -129,17 +129,17 @@ impl ToStr for ParseError {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
match *self {
|
match *self {
|
||||||
ErrorInvalidLength(found) =>
|
ErrorInvalidLength(found) =>
|
||||||
fmt!("Invalid length; expecting 32, 36 or 45 chars, found %u",
|
format!("Invalid length; expecting 32, 36 or 45 chars, found {}",
|
||||||
found),
|
found),
|
||||||
ErrorInvalidCharacter(found, pos) =>
|
ErrorInvalidCharacter(found, pos) =>
|
||||||
fmt!("Invalid character; found `%c` (0x%02x) at offset %u",
|
format!("Invalid character; found `{}` (0x{:02x}) at offset {}",
|
||||||
found, found as uint, pos),
|
found, found as uint, pos),
|
||||||
ErrorInvalidGroups(found) =>
|
ErrorInvalidGroups(found) =>
|
||||||
fmt!("Malformed; wrong number of groups: expected 1 or 5, found %u",
|
format!("Malformed; wrong number of groups: expected 1 or 5, found {}",
|
||||||
found),
|
found),
|
||||||
ErrorInvalidGroupLength(group, found, expecting) =>
|
ErrorInvalidGroupLength(group, found, expecting) =>
|
||||||
fmt!("Malformed; length of group %u was %u, expecting %u",
|
format!("Malformed; length of group {} was {}, expecting {}",
|
||||||
group, found, expecting),
|
group, found, expecting),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ impl Uuid {
|
||||||
pub fn to_simple_str(&self) -> ~str {
|
pub fn to_simple_str(&self) -> ~str {
|
||||||
let mut s: ~[u8] = vec::from_elem(32, 0u8);
|
let mut s: ~[u8] = vec::from_elem(32, 0u8);
|
||||||
for i in range(0u, 16u) {
|
for i in range(0u, 16u) {
|
||||||
let digit = fmt!("%02x", self.bytes[i] as uint);
|
let digit = format!("{:02x}", self.bytes[i] as uint);
|
||||||
s[i*2+0] = digit[0];
|
s[i*2+0] = digit[0];
|
||||||
s[i*2+1] = digit[1];
|
s[i*2+1] = digit[1];
|
||||||
}
|
}
|
||||||
|
@ -324,12 +324,13 @@ impl Uuid {
|
||||||
uf.data1 = to_be32(uf.data1 as i32) as u32;
|
uf.data1 = to_be32(uf.data1 as i32) as u32;
|
||||||
uf.data2 = to_be16(uf.data2 as i16) as u16;
|
uf.data2 = to_be16(uf.data2 as i16) as u16;
|
||||||
uf.data3 = to_be16(uf.data3 as i16) as u16;
|
uf.data3 = to_be16(uf.data3 as i16) as u16;
|
||||||
let s = fmt!("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
let s = format!("{:08x}-{:04x}-{:04x}-{:02x}{:02x}-\
|
||||||
uf.data1 as uint,
|
{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
||||||
uf.data2 as uint, uf.data3 as uint,
|
uf.data1,
|
||||||
uf.data4[0] as uint, uf.data4[1] as uint,
|
uf.data2, uf.data3,
|
||||||
uf.data4[2] as uint, uf.data4[3] as uint, uf.data4[4] as uint,
|
uf.data4[0], uf.data4[1],
|
||||||
uf.data4[5] as uint, uf.data4[6] as uint, uf.data4[7] as uint);
|
uf.data4[2], uf.data4[3], uf.data4[4],
|
||||||
|
uf.data4[5], uf.data4[6], uf.data4[7]);
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,11 +183,11 @@ impl Database {
|
||||||
assert!(os::path_exists(&self.db_filename));
|
assert!(os::path_exists(&self.db_filename));
|
||||||
let f = io::file_reader(&self.db_filename);
|
let f = io::file_reader(&self.db_filename);
|
||||||
match f {
|
match f {
|
||||||
Err(e) => fail!("Couldn't load workcache database %s: %s",
|
Err(e) => fail2!("Couldn't load workcache database {}: {}",
|
||||||
self.db_filename.to_str(), e.to_str()),
|
self.db_filename.to_str(), e.to_str()),
|
||||||
Ok(r) =>
|
Ok(r) =>
|
||||||
match json::from_reader(r) {
|
match json::from_reader(r) {
|
||||||
Err(e) => fail!("Couldn't parse workcache database (from file %s): %s",
|
Err(e) => fail2!("Couldn't parse workcache database (from file {}): {}",
|
||||||
self.db_filename.to_str(), e.to_str()),
|
self.db_filename.to_str(), e.to_str()),
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
let mut decoder = json::Decoder(r);
|
let mut decoder = json::Decoder(r);
|
||||||
|
@ -264,7 +264,7 @@ fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
|
||||||
|
|
||||||
// FIXME(#5121)
|
// FIXME(#5121)
|
||||||
fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
|
fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
|
||||||
debug!("json decoding: %s", s);
|
debug2!("json decoding: {}", s);
|
||||||
do io::with_str_reader(s) |rdr| {
|
do io::with_str_reader(s) |rdr| {
|
||||||
let j = json::from_reader(rdr).unwrap();
|
let j = json::from_reader(rdr).unwrap();
|
||||||
let mut decoder = json::Decoder(j);
|
let mut decoder = json::Decoder(j);
|
||||||
|
@ -321,7 +321,7 @@ impl Exec {
|
||||||
dependency_kind: &str,
|
dependency_kind: &str,
|
||||||
dependency_name: &str,
|
dependency_name: &str,
|
||||||
dependency_val: &str) {
|
dependency_val: &str) {
|
||||||
debug!("Discovering input %s %s %s", dependency_kind, dependency_name, dependency_val);
|
debug2!("Discovering input {} {} {}", dependency_kind, dependency_name, dependency_val);
|
||||||
self.discovered_inputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
|
self.discovered_inputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
|
||||||
dependency_val.to_owned());
|
dependency_val.to_owned());
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ impl Exec {
|
||||||
dependency_kind: &str,
|
dependency_kind: &str,
|
||||||
dependency_name: &str,
|
dependency_name: &str,
|
||||||
dependency_val: &str) {
|
dependency_val: &str) {
|
||||||
debug!("Discovering output %s %s %s", dependency_kind, dependency_name, dependency_val);
|
debug2!("Discovering output {} {} {}", dependency_kind, dependency_name, dependency_val);
|
||||||
self.discovered_outputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
|
self.discovered_outputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
|
||||||
dependency_val.to_owned());
|
dependency_val.to_owned());
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ impl<'self> Prep<'self> {
|
||||||
|
|
||||||
impl<'self> Prep<'self> {
|
impl<'self> Prep<'self> {
|
||||||
pub fn declare_input(&mut self, kind: &str, name: &str, val: &str) {
|
pub fn declare_input(&mut self, kind: &str, name: &str, val: &str) {
|
||||||
debug!("Declaring input %s %s %s", kind, name, val);
|
debug2!("Declaring input {} {} {}", kind, name, val);
|
||||||
self.declared_inputs.insert_work_key(WorkKey::new(kind, name),
|
self.declared_inputs.insert_work_key(WorkKey::new(kind, name),
|
||||||
val.to_owned());
|
val.to_owned());
|
||||||
}
|
}
|
||||||
|
@ -377,17 +377,17 @@ impl<'self> Prep<'self> {
|
||||||
name: &str, val: &str) -> bool {
|
name: &str, val: &str) -> bool {
|
||||||
let k = kind.to_owned();
|
let k = kind.to_owned();
|
||||||
let f = self.ctxt.freshness.get().find(&k);
|
let f = self.ctxt.freshness.get().find(&k);
|
||||||
debug!("freshness for: %s/%s/%s/%s", cat, kind, name, val)
|
debug2!("freshness for: {}/{}/{}/{}", cat, kind, name, val)
|
||||||
let fresh = match f {
|
let fresh = match f {
|
||||||
None => fail!("missing freshness-function for '%s'", kind),
|
None => fail2!("missing freshness-function for '{}'", kind),
|
||||||
Some(f) => (*f)(name, val)
|
Some(f) => (*f)(name, val)
|
||||||
};
|
};
|
||||||
do self.ctxt.logger.write |lg| {
|
do self.ctxt.logger.write |lg| {
|
||||||
if fresh {
|
if fresh {
|
||||||
lg.info(fmt!("%s %s:%s is fresh",
|
lg.info(format!("{} {}:{} is fresh",
|
||||||
cat, kind, name));
|
cat, kind, name));
|
||||||
} else {
|
} else {
|
||||||
lg.info(fmt!("%s %s:%s is not fresh",
|
lg.info(format!("{} {}:{} is not fresh",
|
||||||
cat, kind, name))
|
cat, kind, name))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -418,7 +418,7 @@ impl<'self> Prep<'self> {
|
||||||
&'self self, blk: ~fn(&mut Exec) -> T) -> Work<'self, T> {
|
&'self self, blk: ~fn(&mut Exec) -> T) -> Work<'self, T> {
|
||||||
let mut bo = Some(blk);
|
let mut bo = Some(blk);
|
||||||
|
|
||||||
debug!("exec_work: looking up %s and %?", self.fn_name,
|
debug2!("exec_work: looking up {} and {:?}", self.fn_name,
|
||||||
self.declared_inputs);
|
self.declared_inputs);
|
||||||
let cached = do self.ctxt.db.read |db| {
|
let cached = do self.ctxt.db.read |db| {
|
||||||
db.prepare(self.fn_name, &self.declared_inputs)
|
db.prepare(self.fn_name, &self.declared_inputs)
|
||||||
|
@ -429,14 +429,14 @@ impl<'self> Prep<'self> {
|
||||||
if self.all_fresh("declared input",&self.declared_inputs) &&
|
if self.all_fresh("declared input",&self.declared_inputs) &&
|
||||||
self.all_fresh("discovered input", disc_in) &&
|
self.all_fresh("discovered input", disc_in) &&
|
||||||
self.all_fresh("discovered output", disc_out) => {
|
self.all_fresh("discovered output", disc_out) => {
|
||||||
debug!("Cache hit!");
|
debug2!("Cache hit!");
|
||||||
debug!("Trying to decode: %? / %? / %?",
|
debug2!("Trying to decode: {:?} / {:?} / {}",
|
||||||
disc_in, disc_out, *res);
|
disc_in, disc_out, *res);
|
||||||
Work::from_value(json_decode(*res))
|
Work::from_value(json_decode(*res))
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
debug!("Cache miss!");
|
debug2!("Cache miss!");
|
||||||
let (port, chan) = oneshot();
|
let (port, chan) = oneshot();
|
||||||
let blk = bo.take_unwrap();
|
let blk = bo.take_unwrap();
|
||||||
let chan = Cell::new(chan);
|
let chan = Cell::new(chan);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue