let matches =
&match getopts::groups::getopts(args_, groups) {
Ok(m) => m,
- Err(f) => fail2!(f.to_err_msg())
+ Err(f) => fail2!("{}", f.to_err_msg())
};
if matches.opt_present("h") || matches.opt_present("help") {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
impl cat {
pub fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
impl cat {
fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
return entry.value.clone();
}
}
- fail!();
+ fail2!();
}
#[inline]
#[fixed_stack_segment] #[inline(never)]
pub fn fact(n: uint) -> uint {
unsafe {
- info!("n = %?", n);
+ info2!("n = {}", n);
rustrt::rust_dbg_call(cb, n)
}
}
fn index(&self, _idx: &uint) -> T {
match self {
&just(ref t) => (*t).clone(),
- ¬hing => { fail!(); }
+ ¬hing => { fail2!(); }
}
}
}
// except according to those terms.
pub unsafe fn f(xs: ~[int]) {
- xs.map(|_x| { unsafe fn q() { fail!(); } });
+ xs.map(|_x| { unsafe fn q() { fail2!(); } });
}
pub fn read<T:read>(s: ~str) -> T {
match read::readMaybe(s) {
Some(x) => x,
- _ => fail!("read failed!")
+ _ => fail2!("read failed!")
}
}
pub fn main() {
let (a, b) = f(22_u64, 44u16).f();
- info!("a=%? b=%?", a, b);
+ info2!("a={:?} b={:?}", a, b);
assert_eq!(a, 22u64);
assert_eq!(b, 44u16);
}
let z = f(~x, y);
make_cycle(z);
let (a, b) = z.f();
- info!("a=%u b=%u", *a as uint, b as uint);
+ info2!("a={} b={}", *a as uint, b as uint);
assert_eq!(*a, x);
assert_eq!(b, y);
}
pub fn main() {
let a: int = 10;
- info!(a);
+ info2!("{}", a);
assert_eq!(a * (a - 1), 90);
}
assert_eq!(i32_b << 1, i32_b << 1);
assert_eq!(i32_b >> 1, i32_b >> 1);
assert_eq!(i32_b & i32_b << 1, 0);
- info!(i32_b | i32_b << 1);
+ info2!("{}", i32_b | i32_b << 1);
assert_eq!(i32_b | i32_b << 1, 0x30303030);
}
// xfail-fast
pub fn main() {
- fail!()
+ fail2!()
}
#[main]
fn f<T,U>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
pub fn main() {
- info!("%?", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
- info!("%?", f(5, 6).a);
+ info2!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
+ info2!("{:?}", f(5, 6).a);
}
impl<T:Foo> Foo for @T {
fn foo(&self) -> ~str {
- fmt!("@%s", (**self).foo())
+ format!("@{}", (**self).foo())
}
}
impl Foo for uint {
fn foo(&self) -> ~str {
- fmt!("%u", *self)
+ format!("{}", *self)
}
}
// Check that issue #954 stays fixed
pub fn main() {
- match -1 { -1 => {}, _ => fail!("wat") }
+ match -1 { -1 => {}, _ => fail2!("wat") }
assert_eq!(1-1, 0);
}
let x = Some(p);
match x {
Some(z) => { dispose(z); },
- None => fail!()
+ None => fail2!()
}
}
let mut r = p(1, 2);
unsafe {
- error!("q = %x, r = %x",
+ error2!("q = {:x}, r = {:x}",
(::std::cast::transmute::<*p, uint>(&q)),
(::std::cast::transmute::<*p, uint>(&r)));
}
a ^= b;
b ^= a;
a = a ^ b;
- info!(a);
- info!(b);
+ info2!("{}", a);
+ info2!("{}", b);
assert_eq!(b, 1);
assert_eq!(a, 2);
assert_eq!(!0xf0 & 0xff, 0xf);
// Statement form does not require parentheses:
for i in v.iter() {
- info!("%?", *i);
+ info2!("{:?}", *i);
}
// Usable at all:
assert!(false);
}
match do v.iter().all |e| { e.is_negative() } {
- true => { fail!("incorrect answer."); }
+ true => { fail2!("incorrect answer."); }
false => { }
}
match 3 {
_ if do v.iter().any |e| { e.is_negative() } => {
}
_ => {
- fail!("wrong answer.");
+ fail2!("wrong answer.");
}
}
pub fn main() {
fn as_buf<T>(s: ~str, f: &fn(~str) -> T) -> T { f(s) }
- as_buf(~"foo", |foo: ~str| -> () error!(foo) );
+ as_buf(~"foo", |foo: ~str| -> () error2!("{}", foo) );
}
odds += 1;
}
});
- error!(odds);
+ error2!("{:?}", odds);
assert_eq!(odds, 4);
}
sum += *i * *j;
});
});
- error!(sum);
+ error2!("{:?}", sum);
assert_eq!(sum, 225);
}
);
match s {
~Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)),
- _ => fail!()
+ _ => fail2!()
}
}
- fn check_id(&mut self, s: int) { fail!() }
+ fn check_id(&mut self, s: int) { fail2!() }
}
-
+
pub fn main() { }
add_int(ints, 44);
do iter_ints(ints) |i| {
- error!("int = %d", *i);
+ error2!("int = {}", *i);
true
};
- error!("ints=%?", ints);
+ error2!("ints={:?}", ints);
}
x = @F {f: ~4};
- info!("ptr::to_unsafe_ptr(*b_x) = %x",
+ info2!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
assert_eq!(**b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
x = @F {f: ~4};
- info!("ptr::to_unsafe_ptr(*b_x) = %x",
+ info2!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
*x = @F {f: ~4};
- info!("ptr::to_unsafe_ptr(*b_x) = %x",
+ info2!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
assert_eq!(**b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
*x = @F{f: ~4};
- info!("ptr::to_unsafe_ptr(*b_x) = %x",
+ info2!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
assert_eq!(ptr::to_unsafe_ptr(&(*x)), ptr::to_unsafe_ptr(&(*b_x)));
x = @22;
- info!("ptr::to_unsafe_ptr(*b_x) = %x",
+ info2!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x)));
exp = 4;
}
- info!("*r = %d, exp = %d", *r, exp);
+ info2!("*r = {}, exp = {}", *r, exp);
assert_eq!(*r, exp);
x = @5;
y = @6;
- info!("*r = %d, exp = %d", *r, exp);
+ info2!("*r = {}, exp = {}", *r, exp);
assert_eq!(*r, exp);
assert_eq!(x, @5);
assert_eq!(y, @6);
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
x = @F {f: ~4};
- info!("ptr::to_unsafe_ptr(*b_x) = %x",
+ info2!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
impl Drop for noncopyable {
fn drop(&mut self) {
- error!("dropped");
+ error2!("dropped");
}
}
fn length_is_even(_vs: @int) -> bool { return true; }
fn foo(_acc: int, n: int) {
- if is_odd(n) && length_is_even(some_box(1)) { error!("bloop"); }
+ if is_odd(n) && length_is_even(some_box(1)) { error2!("bloop"); }
}
pub fn main() { foo(67, 5); }
fn length_is_even(_vs: @int) -> bool { return true; }
fn foo(_acc: int, n: int) {
- if is_odd(n) || length_is_even(some_box(1)) { error!("bloop"); }
+ if is_odd(n) || length_is_even(some_box(1)) { error2!("bloop"); }
}
pub fn main() { foo(67, 5); }
pub fn main() {
let foo: int = 17;
let bfoo: Box<int> = Box {c: @foo};
- info!("see what's in our box");
+ info2!("see what's in our box");
assert_eq!(unbox::<int>(bfoo), foo);
}
parent: Option<T>
}
-fn empty<T>() -> Tree<T> { fail!() }
+fn empty<T>() -> Tree<T> { fail2!() }
struct Box {
tree: Tree<@Box>
impl Speak for int {
fn say(&self, s:&str) -> ~str {
- fmt!("%s: %d", s, *self)
+ format!("{}: {}", s, *self)
}
}
impl<T: Speak> Speak for Option<T> {
fn say(&self, s:&str) -> ~str {
match *self {
- None => fmt!("%s - none", s),
+ None => format!("{} - none", s),
Some(ref x) => { ~"something!" + x.say(s) }
}
}
pub fn main() {
let x = 3;
- info!("&x=%x", borrow::to_uint(&x));
+ info2!("&x={:x}", borrow::to_uint(&x));
}
pub fn main() {
let p = @22u;
let r = foo(p);
- info!("r=%u", r);
+ info2!("r={}", r);
assert_eq!(r, 22u);
}
impl Drop for cat {
#[cat_dropper]
- fn drop(&mut self) { error!("%s landed on hir feet" , self . name); }
+ fn drop(&mut self) { error2!("{} landed on hir feet" , self . name); }
}
Actually, cats don't always land on their feet when you drop them.
*/
fn drop(&mut self) {
- error!("%s landed on hir feet", self.name);
+ error2!("{} landed on hir feet", self.name);
}
}
fn print_out(thing: @ToStr, expected: ~str) {
let actual = thing.to_str();
- info!("%s", actual);
+ info2!("{}", actual);
assert_eq!(actual, expected);
}
impl dog {
fn bark(&self) -> int {
- info!("Woof %u %d", *self.barks, *self.volume);
+ info2!("Woof {} {}", *self.barks, *self.volume);
*self.barks += 1u;
if *self.barks % 3u == 0u {
*self.volume += 1;
if *self.barks % 10u == 0u {
*self.volume -= 2;
}
- info!("Grrr %u %d", *self.barks, *self.volume);
+ info2!("Grrr {} {}", *self.barks, *self.volume);
*self.volume
}
}
impl cat {
fn meow(&self) -> uint {
- info!("Meow");
+ info2!("Meow");
*self.meows += 1u;
if *self.meows % 5u == 0u {
*self.how_hungry += 1;
impl cat {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
impl cat {
fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
true
}
- fn find_mut<'a>(&'a mut self, _k: &int) -> Option<&'a mut T> { fail!() }
+ fn find_mut<'a>(&'a mut self, _k: &int) -> Option<&'a mut T> { fail2!() }
fn remove(&mut self, k: &int) -> bool {
if self.find(k).is_some() {
}
}
- fn pop(&mut self, _k: &int) -> Option<T> { fail!() }
+ fn pop(&mut self, _k: &int) -> Option<T> { fail2!() }
- fn swap(&mut self, _k: int, _v: T) -> Option<T> { fail!() }
+ fn swap(&mut self, _k: int, _v: T) -> Option<T> { fail2!() }
}
impl<T> cat<T> {
pub fn get<'a>(&'a self, k: &int) -> &'a T {
match self.find(k) {
Some(v) => { v }
- None => { fail!("epic fail"); }
+ None => { fail2!("epic fail"); }
}
}
impl<T> cat<T> {
fn meow(&mut self) {
self.meows += 1;
- error!("Meow %d", self.meows);
+ error2!("Meow {}", self.meows);
if self.meows % 5 == 0 {
self.how_hungry += 1;
}
impl cat {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
impl cat {
fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
impl cat {
fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
impl cat {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
impl cat {
fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
fn print_out(thing: @ToStr, expected: ~str) {
let actual = thing.to_str();
- info!("%s", actual);
+ info2!("{}", actual);
assert_eq!(actual, expected);
}
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
- error!("OM NOM NOM");
+ error2!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} else {
- error!("Not hungry!");
+ error2!("Not hungry!");
return false;
}
}
impl cat {
fn meow(&mut self) {
- error!("Meow");
+ error2!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
use std::task;
fn adder(x: @int, y: @int) -> int { return *x + *y; }
-fn failer() -> @int { fail!(); }
+fn failer() -> @int { fail2!(); }
pub fn main() {
assert!(task::try(|| {
adder(@2, failer()); ()
pub fn main() {
let (a, b) = f(22_u64, 44u16).f();
- info!("a=%? b=%?", a, b);
+ info2!("a={:?} b={:?}", a, b);
assert_eq!(a, 22u64);
assert_eq!(b, 44u16);
}
let (p, ch) = stream();
let _t = task::spawn(|| child(&ch) );
let y = p.recv();
- error!("received");
- error!(y);
+ error2!("received");
+ error2!("{:?}", y);
assert_eq!(y, 10);
}
fn child(c: &Chan<int>) {
- error!("sending");
+ error2!("sending");
c.send(10);
- error!("value sent");
+ error2!("value sent");
}
pub fn main() {
let x: int = 2 + 2;
- info!("%?", x);
- info!("hello, world");
- info!("%?", 10);
+ info2!("{}", x);
+ info2!("hello, world");
+ info2!("{}", 10);
}
fn main() {
// only fails if debug! evaluates its argument.
- debug!({ if true { fail!() } });
+ debug2!("{:?}", { if true { fail2!() } });
}
fn main() {
// exits early if debug! evaluates its arguments, otherwise it
// will hit the fail.
- debug!({ if true { return; } });
+ debug2!("{:?}", { if true { return; } });
- fail!();
+ fail2!();
}
pub fn main() {
match X {
Baz => {}
- _ => fail!()
+ _ => fail2!()
}
match Y {
Bar(s) => assert!(s == 2654435769),
- _ => fail!()
+ _ => fail2!()
}
match Z {
Quux(d,h) => {
assert_eq!(d, 0x123456789abcdef0);
assert_eq!(h, 0x1234);
}
- _ => fail!()
+ _ => fail2!()
}
}
pub fn method(&self) {
match *self {
V => {}
- VV(*) => fail!()
+ VV(*) => fail2!()
}
}
}
fn f(a: &E) {
match *a {
V => {}
- VV(*) => fail!()
+ VV(*) => fail2!()
}
}
pub fn main() {
match *C {
V0 => (),
- _ => fail!()
+ _ => fail2!()
}
}
pub fn main() {
match C {
- S0 { _ } => fail!(),
+ S0 { _ } => fail2!(),
S1 { u } => assert!(u == 23)
}
}
pub fn main() {
match C0 {
V0 => (),
- _ => fail!()
+ _ => fail2!()
}
match C1 {
V1(n) => assert!(n == 0xDEADBEE),
- _ => fail!()
+ _ => fail2!()
}
}
pub fn main() {
match C[1] {
V1(n) => assert!(n == 0xDEADBEE),
- _ => fail!()
+ _ => fail2!()
}
match C[2] {
V0 => (),
- _ => fail!()
+ _ => fail2!()
}
}
pub fn main() {
match C[1] {
V1(n) => assert!(n == 0xDEADBEE),
- _ => fail!()
+ _ => fail2!()
}
match C[2] {
V0 => (),
- _ => fail!()
+ _ => fail2!()
}
}
pub fn main() {
match X {
Bar => {}
- Baz | Boo => fail!()
+ Baz | Boo => fail2!()
}
match Y {
Baz => {}
- Bar | Boo => fail!()
+ Bar | Boo => fail2!()
}
}
static i: int = 10;
-pub fn main() { info!("%i", i); }
+pub fn main() { info2!("{}", i); }
#[start]
fn start(argc: int, argv: **u8) -> int {
do std::rt::start(argc, argv) {
- info!("creating my own runtime is joy");
+ info2!("creating my own runtime is joy");
}
}
// -*- rust -*-
-pub fn main() { if 1 == 1 { return; } info!("Paul is dead"); }
+pub fn main() { if 1 == 1 { return; } info2!("Paul is dead"); }
-pub fn main() { let x = @mut 5; *x = 1000; info!("%?", *x); }
+pub fn main() { let x = @mut 5; *x = 1000; info2!("{:?}", *x); }
pub struct FailCmp;
impl Eq for FailCmp {
- fn eq(&self, _: &FailCmp) -> bool { fail!("eq") }
+ fn eq(&self, _: &FailCmp) -> bool { fail2!("eq") }
}
impl Ord for FailCmp {
- fn lt(&self, _: &FailCmp) -> bool { fail!("lt") }
+ fn lt(&self, _: &FailCmp) -> bool { fail2!("lt") }
}
impl TotalEq for FailCmp {
- fn equals(&self, _: &FailCmp) -> bool { fail!("equals") }
+ fn equals(&self, _: &FailCmp) -> bool { fail2!("equals") }
}
impl TotalOrd for FailCmp {
- fn cmp(&self, _: &FailCmp) -> Ordering { fail!("cmp") }
+ fn cmp(&self, _: &FailCmp) -> Ordering { fail2!("cmp") }
}
#[deriving(Eq,Ord,TotalEq,TotalOrd)]
#[allow(unreachable_code)];
fn f() {
- fail!();
+ fail2!();
- let _x: int = fail!();
+ let _x: int = fail2!();
}
pub fn main() {
pub fn main() {
let x = Some(0u64);
match x {
- None => fail!(),
+ None => fail2!(),
Some(ref y) => assert!(is_aligned(y))
}
}
};
assert_eq!(expected, V as u64);
assert_eq!(expected, C as u64);
- assert_eq!(fmt!("%?", V), ~"V");
- assert_eq!(fmt!("%?", C), ~"V");
+ assert_eq!(format!("{:?}", V), ~"V");
+ assert_eq!(format!("{:?}", C), ~"V");
}
match Cons(10, @Nil) {
Cons(10, _) => {}
Nil => {}
- _ => fail!()
+ _ => fail2!()
}
}
let v = &"hello";
let y : &str = &"there";
- info!(x);
- info!(y);
+ info2!("{}", x);
+ info2!("{}", y);
assert_eq!(x[0], 'h' as u8);
assert_eq!(x[4], 'o' as u8);
let c = &"cccc";
let cc = &"ccccc";
- info!(a);
+ info2!("{}", a);
assert!(a < b);
assert!(a <= b);
assert!(b >= a);
assert!(b > a);
- info!(b);
+ info2!("{}", b);
assert!(a < c);
assert!(a <= c);
assert!(c >= a);
assert!(c > a);
- info!(c);
+ info2!("{}", c);
assert!(c < cc);
assert!(c <= cc);
assert!(cc >= c);
assert!(cc > c);
- info!(cc);
+ info2!("{}", cc);
}
let c : &[int] = &[2,2,2,2,3];
let cc : &[int] = &[2,2,2,2,2,2];
- info!(a);
+ info2!("{:?}", a);
assert!(a < b);
assert!(a <= b);
assert!(b >= a);
assert!(b > a);
- info!(b);
+ info2!("{:?}", b);
assert!(b < c);
assert!(b <= c);
assert!(c >= a);
assert!(c > a);
- info!(c);
+ info2!("{:?}", c);
assert!(a < cc);
assert!(a <= cc);
assert!(cc >= a);
assert!(cc > a);
- info!(cc);
+ info2!("{:?}", cc);
}
pub fn y() { super::super::foo::x(); }
}
- pub fn x() { info!("x"); }
+ pub fn x() { info2!("x"); }
}
pub fn main() { self::foo::bar::y(); }
}
pub mod bar {
- pub fn x() { info!("x"); }
+ pub fn x() { info2!("x"); }
}
pub fn main() { foo::x(); }
fn test_box() {
fn compare_box(b1: @bool, b2: @bool) -> bool {
- info!(*b1);
- info!(*b2);
+ info2!("{}", *b1);
+ info2!("{}", *b2);
return *b1 == *b2;
}
test_generic::<bool>(@true, compare_box);
fn test_box() {
fn compare_box(b1: ~bool, b2: ~bool) -> bool {
- info!(*b1);
- info!(*b2);
+ info2!("{}", *b1);
+ info2!("{}", *b2);
return *b1 == *b2;
}
test_generic::<bool>(~true, compare_box);
let _x = if true {
10
} else {
- if true { fail!() } else { fail!() }
+ if true { fail2!() } else { fail2!() }
};
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-fn test_if_fail() { let x = if false { fail!() } else { 10 }; assert!((x == 10)); }
+fn test_if_fail() { let x = if false { fail2!() } else { 10 }; assert!((x == 10)); }
fn test_else_fail() {
- let x = if true { 10 } else { fail!() };
+ let x = if true { 10 } else { fail2!() };
assert_eq!(x, 10);
}
fn test_elseif_fail() {
- let x = if false { 0 } else if false { fail!() } else { 10 };
+ let x = if false { 0 } else if false { fail2!() } else { 10 };
assert_eq!(x, 10);
}
// Tests for match as expressions resulting in boxed types
fn test_box() {
- let res = match true { true => { @100 } _ => fail!("wat") };
+ let res = match true { true => { @100 } _ => fail2!("wat") };
assert_eq!(*res, 100);
}
fn test_str() {
let res = match true { true => { ~"happy" },
- _ => fail!("not happy at all") };
+ _ => fail2!("not happy at all") };
assert_eq!(res, ~"happy");
}
let _x =
match true {
true => { 10 }
- false => { match true { true => { fail!() } false => { fail!() } } }
+ false => { match true { true => { fail2!() } false => { fail2!() } } }
};
}
// except according to those terms.
fn test_simple() {
- let r = match true { true => { true } false => { fail!() } };
+ let r = match true { true => { true } false => { fail2!() } };
assert_eq!(r, true);
}
fn test_box() {
- let r = match true { true => { ~[10] } false => { fail!() } };
+ let r = match true { true => { ~[10] } false => { fail2!() } };
assert_eq!(r[0], 10);
}
type compare<T> = &'static fn(@T, @T) -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
- let actual: @T = match true { true => { expected }, _ => fail!() };
+ let actual: @T = match true { true => { expected }, _ => fail2!() };
assert!((eq(expected, actual)));
}
type compare<T> = &'static fn(T, T) -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
- let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") };
+ let actual: T = match true { true => { expected.clone() }, _ => fail2!("wat") };
assert!((eq(expected, actual)));
}
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
let actual: ~T = match true {
true => { expected.clone() },
- _ => fail!("wat")
+ _ => fail2!("wat")
};
assert!((eq(expected, actual)));
}
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true {
true => expected.clone(),
- _ => fail!("wat")
+ _ => fail2!("wat")
};
assert!((eq(expected, actual)));
}
type compare<T> = extern "Rust" fn(T, T) -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
- let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") };
+ let actual: T = match true { true => { expected.clone() }, _ => fail2!("wat") };
assert!((eq(expected, actual)));
}
struct R { i: int }
fn test_rec() {
- let rs = match true { true => R {i: 100}, _ => fail!() };
+ let rs = match true { true => R {i: 100}, _ => fail2!() };
assert_eq!(rs.i, 100);
}
// Tests for match as expressions resulting in boxed types
fn test_box() {
- let res = match true { true => { ~100 }, _ => fail!() };
+ let res = match true { true => { ~100 }, _ => fail2!() };
assert_eq!(*res, 100);
}
#[fixed_stack_segment]
fn count(n: uint) -> uint {
unsafe {
- info!("n = %?", n);
+ info2!("n = {}", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
let result = count(1000u);
- info!("result = %?", result);
+ info2!("result = {}", result);
assert_eq!(result, 1000u);
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
- info!("n = %?", n);
+ info2!("n = {}", n);
rustrt::rust_dbg_call(cb, n)
}
}
// has a large stack)
do task::spawn {
let result = count(1000u);
- info!("result = %?", result);
+ info2!("result = {}", result);
assert_eq!(result, 1000u);
};
}
#[fixed_stack_segment] #[inline(never)]
fn fact(n: uint) -> uint {
unsafe {
- info!("n = %?", n);
+ info2!("n = {}", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
let result = fact(10u);
- info!("result = %?", result);
+ info2!("result = {}", result);
assert_eq!(result, 3628800u);
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
- info!("n = %?", n);
+ info2!("n = {}", n);
rustrt::rust_dbg_call(cb, n)
}
}
// has a large stack)
do task::spawn {
let result = count(12u);
- info!("result = %?", result);
+ info2!("result = {}", result);
assert_eq!(result, 2048u);
};
}
#[fixed_stack_segment] #[inline(never)]
fn fact(n: uint) -> uint {
unsafe {
- info!("n = %?", n);
+ info2!("n = {}", n);
externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
}
}
pub fn main() {
let result = fact(10u);
- info!("result = %?", result);
+ info2!("result = {}", result);
assert_eq!(result, 3628800u);
}
do 10u.times {
do task::spawn {
let result = count(5u);
- info!("result = %?", result);
+ info2!("result = {}", result);
assert_eq!(result, 16u);
};
}
fn f(x: int) -> int {
// info!("in f:");
- info!(x);
+ info2!("{}", x);
if x == 1 {
// info!("bottoming out");
let y: int = x * f(x - 1);
// info!("returned");
- info!(y);
+ info2!("{}", y);
return y;
}
}
}
pub fn main() {
- error!(match red {
+ error2!("{}", match red {
red => { 1 }
green => { 2 }
blue => { 3 }
fn foo(n: float) -> float { return n + 0.12345; }
let n: float = 0.1;
let m: float = foo(n);
- info!(m);
+ info2!("{}", m);
}
pub fn main() {
let pi = 3.1415927;
- info!(-pi * (pi + 2.0 / pi) - pi * 5.0);
+ info2!("{:?}", -pi * (pi + 2.0 / pi) - pi * 5.0);
if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0
|| pi > 1.0 {
- info!("yes");
+ info2!("yes");
}
}
// except according to those terms.
fn f() {
- info!("This is a bare function");
+ info2!("This is a bare function");
}
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub fn main() { let x: ~[int] = ~[]; for _ in x.iter() { fail!("moop"); } }
+pub fn main() { let x: ~[int] = ~[]; for _ in x.iter() { fail2!("moop"); } }
let mut j: int = 0;
do pairs() |p| {
let (_0, _1) = p;
- info!(_0);
- info!(_1);
+ info2!("{}", _0);
+ info2!("{}", _1);
assert_eq!(_0 + 10, i);
i += 1;
j = _1;
// -*- rust -*-
pub fn main() {
let mut sum: int = 0;
- do first_ten |i| { info!("main"); info!(i); sum = sum + i; }
- info!("sum");
- info!(sum);
+ do first_ten |i| { info2!("main"); info2!("{}", i); sum = sum + i; }
+ info2!("sum");
+ info2!("{}", sum);
assert_eq!(sum, 45);
}
fn first_ten(it: &fn(int)) {
let mut i: int = 0;
- while i < 10 { info!("first_ten"); it(i); i = i + 1; }
+ while i < 10 { info2!("first_ten"); it(i); i = i + 1; }
}
pub fn main() {
let expected = @100;
let actual = id::<@int>(expected);
- info!(*actual);
+ info2!("{:?}", *actual);
assert_eq!(*expected, *actual);
}
pub fn main() {
let expected = ~100;
let actual = id::<~int>(expected.clone());
- info!(*actual);
+ info2!("{:?}", *actual);
assert_eq!(*expected, *actual);
}
pub fn main() {
let b = f::<int>(10);
- info!(b.a);
- info!(b.b);
+ info2!("{:?}" ,b.a);
+ info2!("{:?}", b.b);
assert_eq!(b.a, 10);
assert_eq!(b.b, 10);
}
fn f<T>(x: @T) -> @T { return x; }
-pub fn main() { let x = f(@3); info!(*x); }
+pub fn main() { let x = f(@3); info2!("{:?}", *x); }
fn f<T>(x: ~T) -> ~T { return x; }
-pub fn main() { let x = f(~3); info!(*x); }
+pub fn main() { let x = f(~3); info2!("{:?}", *x); }
let p: Triple = Triple {x: 65, y: 66, z: 67};
let mut q: Triple = Triple {x: 68, y: 69, z: 70};
y = id::<int>(x);
- info!(y);
+ info2!("{}", y);
assert_eq!(x, y);
b = id::<char>(a);
- info!(b);
+ info2!("{}", b);
assert_eq!(a, b);
q = id::<Triple>(p);
x = p.z;
y = q.z;
- info!(y);
+ info2!("{}", y);
assert_eq!(x, y);
}
fn altfoo<T>(f: foo<T>) {
let mut hit = false;
- match f { arm::<T>(_x) => { info!("in arm"); hit = true; } }
+ match f { arm::<T>(_x) => { info2!("in arm"); hit = true; } }
assert!((hit));
}
pub fn main() {
let nop: noption<int> = some::<int>(5);
- match nop { some::<int>(n) => { info!(n); assert!((n == 5)); } }
+ match nop { some::<int>(n) => { info2!("{:?}", n); assert!((n == 5)); } }
let nop2: noption<Pair> = some(Pair{x: 17, y: 42});
match nop2 {
some(t) => {
- info!(t.x);
- info!(t.y);
+ info2!("{:?}", t.x);
+ info2!("{:?}", t.y);
assert_eq!(t.x, 17);
assert_eq!(t.y, 42);
}
fn mk() -> int { return 1; }
-fn chk(a: int) { info!(a); assert!((a == 1)); }
+fn chk(a: int) { info2!("{}", a); assert!((a == 1)); }
fn apply<T>(produce: extern fn() -> T,
consume: extern fn(T)) {
fn get_third<T>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
pub fn main() {
- info!(get_third((1, 2, 3)));
+ info2!("{:?}", get_third((1, 2, 3)));
assert_eq!(get_third((1, 2, 3)), 3);
assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8);
}
match getopts(args, opts) {
Ok(ref m) =>
assert!(!m.opt_present("b")),
- Err(ref f) => fail!((*f).clone().to_err_msg())
+ Err(ref f) => fail2!("{:?}", (*f).clone().to_err_msg())
};
}
return;
}
let (pp, cc) = stream();
- error!("sending find_reducer");
+ error2!("sending find_reducer");
ctrl.send(find_reducer(key.as_bytes().to_owned(), cc));
- error!("receiving");
+ error2!("receiving");
let c = pp.recv();
- error!(c);
+ error2!("{:?}", c);
im.insert(key, c);
}
pub fn main() {
- let i: int = if false { fail!() } else { 5 };
- info!(i);
+ let i: int = if false { fail2!() } else { 5 };
+ info2!("{:?}", i);
}
fn foo(x: uint) {
if even(x) {
- info!(x);
+ info2!("{}", x);
} else {
- fail!();
+ fail2!();
}
}
use dug::too::greedily::and::too::deep::*;
mod module_of_many_things {
- pub fn f1() { info!("f1"); }
- pub fn f2() { info!("f2"); }
- fn f3() { info!("f3"); }
- pub fn f4() { info!("f4"); }
+ pub fn f1() { info2!("f1"); }
+ pub fn f2() { info2!("f2"); }
+ fn f3() { info2!("f3"); }
+ pub fn f4() { info2!("f4"); }
}
mod dug {
pub mod and {
pub mod too {
pub mod deep {
- pub fn nameless_fear() { info!("Boo!"); }
- pub fn also_redstone() { info!("Whatever."); }
+ pub fn nameless_fear() { info2!("Boo!"); }
+ pub fn also_redstone() { info2!("Whatever."); }
}
}
}
// except according to those terms.
mod foo {
- pub fn x(y: int) { info!(y); }
+ pub fn x(y: int) { info2!("{:?}", y); }
}
mod bar {
use zed::bar;
mod zed {
- pub fn bar() { info!("bar"); }
+ pub fn bar() { info2!("bar"); }
}
pub fn main() { bar(); }
mod baz {
pub mod zed {
- pub fn bar() { info!("bar2"); }
+ pub fn bar() { info2!("bar2"); }
}
}
use zed::bar;
mod zed {
- pub fn bar() { info!("bar"); }
+ pub fn bar() { info2!("bar"); }
}
pub fn main() { let _zed = 42; bar(); }
mod foo {
pub use foo::zed::bar;
pub mod zed {
- pub fn bar() { info!("foo"); }
+ pub fn bar() { info2!("foo"); }
}
}
mod foo {
pub mod zed {
- pub fn baz() { info!("baz"); }
+ pub fn baz() { info2!("baz"); }
}
}
mod bar {
mod foo {
pub mod zed {
- pub fn baz() { info!("baz"); }
+ pub fn baz() { info2!("baz"); }
}
}
mod bar {
use z = foo::x;
mod foo {
- pub fn x(y: int) { info!(y); }
+ pub fn x(y: int) { info2!("{}", y); }
}
pub fn main() { x(10); z(10); }
// -*- rust -*-
mod inner {
pub mod inner2 {
- pub fn hello() { info!("hello, modular world"); }
+ pub fn hello() { info2!("hello, modular world"); }
}
pub fn hello() { inner2::hello(); }
}
assert_eq!(v[3i8], 3);
assert_eq!(v[3u32], 3);
assert_eq!(v[3i32], 3);
- info!(v[3u8]);
+ info2!("{}", v[3u8]);
assert_eq!(s[3u], 'd' as u8);
assert_eq!(s[3u8], 'd' as u8);
assert_eq!(s[3i8], 'd' as u8);
assert_eq!(s[3u32], 'd' as u8);
assert_eq!(s[3i32], 'd' as u8);
- info!(s[3u8]);
+ info2!("{}", s[3u8]);
}
// except according to those terms.
pub fn main() {
- let early_error: &'static fn(&str) -> ! = |_msg| { fail!() };
+ let early_error: &'static fn(&str) -> ! = |_msg| { fail2!() };
}
pub fn main() {
let mut m = HashMap::new();
m.insert("foo".as_bytes().to_owned(), "bar".as_bytes().to_owned());
- error!(m);
+ error2!("{:?}", m);
}
break;
}
- error!("%?", x);
+ error2!("{:?}", x);
assert_eq!(x, 42);
}
impl<A> foo<A> {
pub fn bar<B,C:clam<A>>(&self, _c: C) -> B {
- fail!();
+ fail2!();
}
}
struct foo(int);
impl foo {
- pub fn bar<B,C:clam<B>>(&self, _c: C) -> B { fail!(); }
+ pub fn bar<B,C:clam<B>>(&self, _c: C) -> B { fail2!(); }
}
pub fn main() { }
}
impl A for E {
- fn b<F,G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
+ fn b<F,G>(_x: F) -> F { fail2!() }
+ //~^ ERROR in method `b`, type parameter 0 has 1 bound, but
}
pub fn main() {}
}
fn meow() {
- error!("meow")
+ error2!("meow")
}
fn cat() -> cat {
}
mod rusti {
- pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail!(); }
- pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail!(); }
- pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail!(); }
+ pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail2!(); }
+ pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail2!(); }
+ pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail2!(); }
}
// We should consider moving this to ::std::unsafe, although I
// The receiver will eventually clean this up.
unsafe { forget(p); }
}
- full => { fail!("duplicate send") }
+ full => { fail2!("duplicate send") }
blocked => {
// The receiver will eventually clean this up.
}
full => {
// This is impossible
- fail!("you dun goofed")
+ fail2!("you dun goofed")
}
terminated => {
// I have to clean up, use drop_glue
}
blocked => {
// this shouldn't happen.
- fail!("terminating a blocked packet")
+ fail2!("terminating a blocked packet")
}
terminated | full => {
// I have to clean up, use drop_glue
let _addr : *::pipes::send_packet<pong> = match &p {
&ping(ref x) => { cast::transmute(x) }
};
- fail!()
+ fail2!()
}
}
let _addr : *::pipes::send_packet<ping> = match &p {
&pong(ref x) => { cast::transmute(x) }
};
- fail!()
+ fail2!()
}
}
pub fn do_pong(c: pong) -> (ping, ()) {
let packet = ::pipes::recv(c);
if packet.is_none() {
- fail!("sender closed the connection")
+ fail2!("sender closed the connection")
}
(pingpong::liberate_pong(packet.unwrap()), ())
}
pub fn do_ping(c: ping) -> (pong, ()) {
let packet = ::pipes::recv(c);
if packet.is_none() {
- fail!("sender closed the connection")
+ fail2!("sender closed the connection")
}
(pingpong::liberate_ping(packet.unwrap()), ())
}
fn client(chan: pingpong::client::ping) {
let chan = pingpong::client::do_ping(chan);
- error!(~"Sent ping");
+ error2!("Sent ping");
let (_chan, _data) = pingpong::client::do_pong(chan);
- error!(~"Received pong");
+ error2!("Received pong");
}
fn server(chan: pingpong::server::ping) {
let (chan, _data) = pingpong::server::do_ping(chan);
- error!(~"Received ping");
+ error2!("Received ping");
let _chan = pingpong::server::do_pong(chan);
- error!(~"Sent pong");
+ error2!("Sent pong");
}
pub fn main() {
use std::hashmap::HashMap;
fn add_interfaces(managed_ip: ~str, device: HashMap<~str, int>) {
- error!("%s, %?", managed_ip, device.get(&~"interfaces"));
+ error2!("{}, {:?}", managed_ip, device.get(&~"interfaces"));
}
pub fn main() {}
(*s).clone()
}
option::Some(value) => {
- error!("%s was expected to be a string but is a %?", key, value);
+ error2!("{} was expected to be a string but is a {:?}", key, value);
default
}
option::None => {
match &data {
&extra::json::Object(ref interface) => {
let name = lookup((*interface).clone(), ~"ifDescr", ~"");
- let label = fmt!("%s-%s", managed_ip, name);
+ let label = format!("{}-{}", managed_ip, name);
(label, bool_value(false))
}
_ => {
- error!("Expected dict for %s interfaces but found %?", managed_ip, data);
+ error2!("Expected dict for {} interfaces but found {:?}", managed_ip, data);
(~"gnos:missing-interface", bool_value(true))
}
}
}
_ =>
{
- error!("Expected list for %s interfaces but found %?", managed_ip,
+ error2!("Expected list for {} interfaces but found {:?}", managed_ip,
device.get(&~"interfaces"));
~[]
}
'.' => { earth }
' ' => { empty }
_ => {
- error!("invalid square: %?", c);
- fail!()
+ error2!("invalid square: {:?}", c);
+ fail2!()
}
}
}
// x.f();
// y.f();
// (*z).f();
- error!("ok so far...");
+ error2!("ok so far...");
z.f(); //segfault
}
// except according to those terms.
pub fn main() {
- error!(("hi there!", "you"));
+ error2!("{:?}", ("hi there!", "you"));
}
{
if actual != expected
{
- io::stderr().write_line(fmt!("Found %s, but expected %s", actual, expected));
+ io::stderr().write_line(format!("Found {}, but expected {}", actual,
+ expected));
return false;
}
return true;
let t = Text(@~"foo");
let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo");
- let v = fmt!("%?", u); // this is the line that causes the seg fault
+ let v = format!("{:?}", u); // this is the line that causes the seg fault
assert!(v.len() > 0);
}
// this little helper.
pub fn check_strs(actual: &str, expected: &str) -> bool {
if actual != expected {
- io::stderr().write_line(fmt!("Found:\n%s\nbut expected\n%s", actual, expected));
+ io::stderr().write_line(format!("Found:\n{}\nbut expected\n{}", actual, expected));
return false;
}
return true;
|buffer|
{
for i in range(0u, buffer.len()) {
- error!("%?: %f", i, buffer[i])
+ error2!("{}: {}", i, buffer[i])
}
};
samples_chan.send(GetSamples(name.clone(), callback));
match BadChar {
_ if true => BadChar,
- BadChar | BadSyntax => fail!() ,
+ BadChar | BadSyntax => fail2!() ,
};
}
let doc = json::from_str("").unwrap();
let mut decoder = json::Decoder(doc);
let _v: T = Decodable::decode(&mut decoder);
- fail!()
+ fail2!()
}
pub fn main() {}
fn print_name(x: &Debuggable)
{
- println(fmt!("debug_name = %s", x.debug_name()));
+ println!("debug_name = {}", x.debug_name());
}
pub fn main() {
fn foo(self_: &A) -> int {
if true {
- fail!()
+ fail2!()
} else {
*bar(self_.bar)
}
}
fn bar<'r>(_: &'r mut int) -> &'r int {
- fail!()
+ fail2!()
}
struct A {
impl Barks for Dog {
fn bark(&self) -> ~str {
- return fmt!("woof! (I'm %s)", self.name);
+ return format!("woof! (I'm {})", self.name);
}
}
let barker = [snoopy as ~Barks, bubbles as ~Barks];
for pup in barker.iter() {
- println(fmt!("%s", pup.bark()));
+ println!("{}", pup.bark());
}
}
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
pub fn main() {
for &v in V.iter() {
- println(fmt!("%?", v.vec));
+ println!("{:?}", v.vec);
}
}
}
impl Inner for int {
- fn print(&self) { print(fmt!("Inner: %d\n", *self)); }
+ fn print(&self) { print(format!("Inner: {}\n", *self)); }
}
struct Outer<'self> {
let mut your_favorite_numbers = @[1,2,3];
let mut my_favorite_numbers = @[4,5,6];
let f = your_favorite_numbers + my_favorite_numbers;
- println(fmt!("The third favorite number is %?.", f))
+ println!("The third favorite number is {:?}.", f)
}
impl<E> Graph<int, E> for HashMap<int, int> {
fn f(&self, _e: E) {
- fail!();
+ fail2!();
}
}
let a = A { x: 0 };
let A { x: ref x } = a;
- info!("%?", x)
+ info2!("{:?}", x)
}
match a {
A { x : ref x } => {
- info!("%?", x)
+ info2!("{:?}", x)
}
}
}
pub fn main() {
let test = &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32];
- println(fmt!("%b",test==test1.pattern));
+ println(format!("{}",test==test1.pattern));
}
let sa = A { a: 100 };
let sb = B { b: 200, pa: &sa };
- debug!("sa is %?", sa);
- debug!("sb is %?", sb);
- debug!("sb.pa is %?", sb.get_pa());
+ debug2!("sa is {:?}", sa);
+ debug2!("sb is {:?}", sb);
+ debug2!("sb.pa is {:?}", sb.get_pa());
}
fn assert_repr_eq<T>(obj : T, expected : ~str) {
- assert_eq!(expected, fmt!("%?", obj));
+ assert_eq!(expected, format!("{:?}", obj));
}
pub fn main() {
fn test_stack_assign() {
let s: ~str = ~"a";
- info!(s.clone());
+ info2!("{}", s.clone());
let t: ~str = ~"a";
assert!(s == t);
let u: ~str = ~"b";
assert!((s != u));
}
-fn test_heap_log() { let s = ~"a big ol' string"; info!(s); }
+fn test_heap_log() { let s = ~"a big ol' string"; info2!("{}", s); }
fn test_stack_add() {
assert_eq!(~"a" + "b", ~"ab");
let mut s = ~"a";
s.push_str("b");
- info!(s.clone());
+ info2!("{}", s.clone());
assert_eq!(s, ~"ab");
let mut s = ~"c";
extern mod extra;
pub fn f() {
- fmt!("test%s", "s");
+ format!("test{}", "s");
#[attr = "val"]
fn g() { }
}
pub fn main() {
let mut sum: int = 0;
range_(0, 100, |x| sum += x );
- info!(sum);
+ info2!("{}", sum);
}
pub fn main() {
let e = @mut Refs{refs: ~[], n: 0};
- let _f: &fn() = || error!(e.n);
+ let _f: &fn() = || error2!("{}", e.n);
e.refs.push(1);
}
let r = f(s);
return (r);
}
- fail!();
+ fail2!();
}
fn apply<T>(s: ~str, f: &fn(~str) -> T) -> T {
fn invoke(f: &fn()) { f(); }
let k = ~22;
let _u = A {a: k.clone()};
- invoke(|| error!(k.clone()) )
+ invoke(|| error2!("{:?}", k.clone()) )
}
let x = 1 == 2 || 3 == 3;
assert!((x));
let mut y: int = 10;
- info!(x || incr(&mut y));
+ info2!("{:?}", x || incr(&mut y));
assert_eq!(y, 10);
if true && x { assert!((true)); } else { assert!((false)); }
}
-fn foo(x: int) { info!(x); }
+fn foo(x: int) { info2!("{}", x); }
pub fn main() { let mut x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); }
pub fn main() {
let x = ~[1, 2, 3];
let mut y = 0;
- for i in x.iter() { info!(*i); y += *i; }
- info!(y);
+ for i in x.iter() { info2!("{:?}", *i); y += *i; }
+ info2!("{:?}", y);
assert_eq!(y, 6);
let s = ~"hello there";
let mut i: int = 0;
// ...
i += 1;
- info!(i);
- info!(c);
+ info2!("{:?}", i);
+ info2!("{:?}", c);
}
assert_eq!(i, 11);
}
v = 3;
break;
}
- info!("%d", v);
+ info2!("{}", v);
}
pub fn main() {
-pub fn main() { if false { error!(~"foo" + "bar"); } }
+pub fn main() { if false { error2!("{}", ~"foo" + "bar"); } }
}
fn check_log<T>(exp: ~str, v: T) {
- assert_eq!(exp, fmt!("%?", v));
+ assert_eq!(exp, format!("{:?}", v));
}
pub fn main() {
let x = list::from_vec([a(22u), b(~"hi")]);
let exp = ~"@Cons(a(22u), @Cons(b(~\"hi\"), @Nil))";
- let act = fmt!("%?", x);
+ let act = format!("{:?}", x);
assert!(act == exp);
check_log(exp, x);
}
}
pub fn main() {
- assert_eq!(~"a(22u)", fmt!("%?", a(22u)));
- assert_eq!(~"b(~\"hi\")", fmt!("%?", b(~"hi")));
- assert_eq!(~"c", fmt!("%?", c));
- assert_eq!(~"d", fmt!("%?", d));
+ assert_eq!(~"a(22u)", format!("{:?}", a(22u)));
+ assert_eq!(~"b(~\"hi\")", format!("{:?}", b(~"hi")));
+ assert_eq!(~"c", format!("{:?}", c));
+ assert_eq!(~"d", format!("{:?}", d));
}
fn f<T,U:'static>() {
let sim = mk::<U>();
- error!(sim);
+ error2!("{:?}", sim);
}
pub fn main() {
}
pub fn main() {
- info!(1);
- info!(2.0);
- warn!(Three);
- error!(~[4]);
+ info2!("{}", 1);
+ info2!("{}", 2.0);
+ warn2!("{:?}", Three);
+ error2!("{:?}", ~[4]);
}
let act = sys::log_str(&~[1, 2, 3]);
assert_eq!(~"~[1, 2, 3]", act);
- let act = fmt!("%?/%6?", ~[1, 2, 3], ~"hi");
- assert_eq!(act, ~"~[1, 2, 3]/ ~\"hi\"");
+ let act = format!("{:?}/{:6?}", ~[1, 2, 3], ~"hi");
+ assert_eq!(act, ~"~[1, 2, 3]/~\"hi\" ");
}
pub fn main() {
let mut i = 0u;
loop {
- error!(~"a");
+ error2!("a");
i += 1u;
if i == 10u {
break;
if i == 21u {
break;
}
- error!(~"b");
+ error2!("b");
is_even = false;
i += 1u;
if i % 2u != 0u {
}
assert!(!is_even);
loop {
- error!(~"c");
+ error2!("c");
if i == 22u {
break;
}
Some($pat) => {
$res
}
- _ => { fail!(); }
+ _ => { fail2!(); }
}
})
match ref_string {
"a" => ~"found a",
"b" => ~"found b",
- s => fmt!("not found (%s)", s)
+ s => format!("not found ({})", s)
}
}
match (ref_1, ref_2) {
("a", "b") => ~"found a,b",
("b", "c") => ~"found b,c",
- (s1, s2) => fmt!("not found (%s, %s)", s1, s2)
+ (s1, s2) => format!("not found ({}, {})", s1, s2)
}
}
// except according to those terms.
// n.b. This was only ever failing with optimization disabled.
-fn a() -> int { match return 1 { 2 => 3, _ => fail!() } }
+fn a() -> int { match return 1 { 2 => 3, _ => fail2!() } }
pub fn main() { a(); }
pub fn main() {
let i: int =
- match Some::<int>(3) { None::<int> => { fail!() } Some::<int>(_) => { 5 } };
- info!("%?", i);
+ match Some::<int>(3) { None::<int> => { fail2!() } Some::<int>(_) => { 5 } };
+ info2!("{}", i);
}
pub fn main() {
let e = Bar;
match e {
- Foo{f: _f} => fail!(),
+ Foo{f: _f} => fail2!(),
_ => (),
}
}
let e = Foo{f: 1};
match e {
Foo{_} => (),
- _ => fail!(),
+ _ => fail2!(),
}
match e {
Foo{f: _f} => (),
- _ => fail!(),
+ _ => fail2!(),
}
}
return;
}
-pub fn main() { info!("hello"); foo::<int>(Some::<int>(5)); }
+pub fn main() { info2!("hello"); foo::<int>(Some::<int>(5)); }
enum t { make_t(@int), clam, }
fn foo(s: @int) {
- info!(::std::sys::refcount(s));
+ info2!("{:?}", ::std::sys::refcount(s));
let count = ::std::sys::refcount(s);
let x: t = make_t(s); // ref up
assert_eq!(::std::sys::refcount(s), count + 1u);
- info!(::std::sys::refcount(s));
+ info2!("{:?}", ::std::sys::refcount(s));
match x {
make_t(y) => {
- info!("%?", y); // ref up then down
+ info2!("{:?}", y); // ref up then down
}
- _ => { info!("?"); fail!(); }
+ _ => { info2!("?"); fail2!(); }
}
- info!(::std::sys::refcount(s));
+ info2!("{:?}", ::std::sys::refcount(s));
assert_eq!(::std::sys::refcount(s), count + 1u);
let _ = ::std::sys::refcount(s); // don't get bitten by last-use.
}
foo(s); // ref up then down
- info!("%u", ::std::sys::refcount(s));
+ info2!("{}", ::std::sys::refcount(s));
let count2 = ::std::sys::refcount(s);
assert_eq!(count, count2);
}
fn altlit(f: int) -> int {
match f {
- 10 => { info!("case 10"); return 20; }
- 11 => { info!("case 11"); return 22; }
- _ => fail!("the impossible happened")
+ 10 => { info2!("case 10"); return 20; }
+ 11 => { info2!("case 11"); return 22; }
+ _ => fail2!("the impossible happened")
}
}
fn foo(x: maybe<int>) {
match x {
- nothing => { error!("A"); }
- just(_a) => { error!("B"); }
+ nothing => { error2!("A"); }
+ just(_a) => { error2!("B"); }
}
}
assert_eq!(a, ~"a");
assert_eq!(b, ~"b");
},
- _ => fail!(),
+ _ => fail2!(),
}
}
assert_eq!(a, 2);
assert_eq!(b, 3);
},
- _ => fail!(),
+ _ => fail2!(),
}
}
assert_eq!(*a, 2);
assert_eq!(*b, 3);
},
- _ => fail!(),
+ _ => fail2!(),
}
}
assert_eq!(a, 2);
assert_eq!(b, 3);
},
- _ => fail!(),
+ _ => fail2!(),
}
}
assert_eq!(*a, 2);
assert_eq!(*b, 3);
},
- _ => fail!(),
+ _ => fail2!(),
}
}
pub fn main() {
match 5u {
1u..5u => {}
- _ => fail!("should match range"),
+ _ => fail2!("should match range"),
}
match 5u {
- 6u..7u => fail!("shouldn't match range"),
+ 6u..7u => fail2!("shouldn't match range"),
_ => {}
}
match 5u {
- 1u => fail!("should match non-first range"),
+ 1u => fail2!("should match non-first range"),
2u..6u => {}
- _ => fail!("math is broken")
+ _ => fail2!("math is broken")
}
match 'c' {
'a'..'z' => {}
- _ => fail!("should suppport char ranges")
+ _ => fail2!("should suppport char ranges")
}
match -3 {
-7..5 => {}
- _ => fail!("should match signed range")
+ _ => fail2!("should match signed range")
}
match 3.0 {
1.0..5.0 => {}
- _ => fail!("should match float range")
+ _ => fail2!("should match float range")
}
match -1.5 {
-3.6..3.6 => {}
- _ => fail!("should match negative float range")
+ _ => fail2!("should match negative float range")
}
}
Some(ref z) if z.with(|b| *b) => {
do z.with |b| { assert!(*b); }
},
- _ => fail!()
+ _ => fail2!()
}
}
}
// Issue #53
pub fn main() {
- match ~"test" { ~"not-test" => fail!(), ~"test" => (), _ => fail!() }
+ match ~"test" { ~"not-test" => fail2!(), ~"test" => (), _ => fail2!() }
enum t { tag1(~str), tag2, }
match tag1(~"test") {
- tag2 => fail!(),
- tag1(~"not-test") => fail!(),
+ tag2 => fail2!(),
+ tag1(~"not-test") => fail2!(),
tag1(~"test") => (),
- _ => fail!()
+ _ => fail2!()
}
- let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() };
+ let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail2!() };
assert_eq!(x, 1);
- match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() }
+ match ~"a" { ~"a" => { } ~"b" => { }, _ => fail2!() }
}
pub fn main() {
let f = Foo{f: 1};
match f {
- Foo{f: 0} => fail!(),
+ Foo{f: 0} => fail2!(),
Foo{_} => (),
}
match f {
- Foo{f: 0} => fail!(),
+ Foo{f: 0} => fail2!(),
Foo{f: _f} => (),
}
match f {
- Foo{f: 0} => fail!(),
+ Foo{f: 0} => fail2!(),
_ => (),
}
}
pub fn main() {
match ~100 {
~x => {
- info!("%?", x);
+ info2!("{:?}", x);
assert_eq!(x, 100);
}
}
Some(num) => num as u32
};
assert_eq!(f, 1234u32);
- error!(f)
+ error2!("{}", f)
}
unsafe {
let addr = rusti::morestack_addr();
assert!(addr.is_not_null());
- error!("%?", addr);
+ error2!("{}", addr);
}
}
grow(&mut v);
grow(&mut v);
let len = v.len();
- info!(len);
+ info2!("{}", len);
assert_eq!(len, 3 as uint);
}
pub fn main() {
match -5 {
-5 => {}
- _ => { fail!() }
+ _ => { fail2!() }
}
}
// except according to those terms.
-fn baz() -> ! { fail!(); }
+fn baz() -> ! { fail2!(); }
fn foo() {
match Some::<int>(5) {
Some::<int>(_x) => {
let mut bar;
match None::<int> { None::<int> => { bar = 5; } _ => { baz(); } }
- info!(bar);
+ info2!("{:?}", bar);
}
- None::<int> => { info!("hello"); }
+ None::<int> => { info2!("hello"); }
}
}
fn nested(o: t) {
match o {
- bar(_i, Some::<int>(_)) => { error!("wrong pattern matched"); fail!(); }
- _ => { error!("succeeded"); }
+ bar(_i, Some::<int>(_)) => { error2!("wrong pattern matched"); fail2!(); }
+ _ => { error2!("succeeded"); }
}
}
pub fn main() {
match A {a: 10, b: @20} {
x@A {a, b: @20} => { assert!(x.a == 10); assert!(a == 10); }
- A {b: _b, _} => { fail!(); }
+ A {b: _b, _} => { fail2!(); }
}
let mut x@B {b, _} = B {a: 10, b: C {c: 20}};
x.b.c = 30;
impl ToStr for Thingy {
fn to_str(&self) -> ~str {
- fmt!("{ x: %d, y: %d }", self.x, self.y)
+ format!("\\{ x: {}, y: {} \\}", self.x, self.y)
}
}
pub fn main() {
let mut x: int = 1;
x *= 2;
- info!(x);
+ info2!("{}", x);
assert_eq!(x, 2);
x += 3;
- info!(x);
+ info2!("{}", x);
assert_eq!(x, 5);
x *= x;
- info!(x);
+ info2!("{}", x);
assert_eq!(x, 25);
x /= 5;
- info!(x);
+ info2!("{}", x);
assert_eq!(x, 5);
}
fn unwrap<T>(o: Option<T>) -> T {
match o {
Some(v) => v,
- None => fail!()
+ None => fail2!()
}
}
while b <= 32u {
0u << b;
b <<= 1u;
- info!(b);
+ info2!("{:?}", b);
}
}
return pair.value.clone();
}
}
- fail!("No value found for key: %?", index);
+ fail2!("No value found for key: {:?}", index);
}
}
pub fn main() {
let x = true;
if x { let mut i = 10; while i > 0 { i -= 1; } }
- match x { true => { info!("right"); } false => { info!("wrong"); } }
+ match x { true => { info2!("right"); } false => { info2!("wrong"); } }
}
#[allow(unreachable_code)];
// -*- rust -*-
-fn dont_call_me() { fail!(); info!(1); }
+fn dont_call_me() { fail2!(); info2!("{}", 1); }
pub fn main() { }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-fn magic(x: A) { info!(x); }
-fn magic2(x: @int) { info!(x); }
+fn magic(x: A) { info2!("{:?}", x); }
+fn magic2(x: @int) { info2!("{:?}", x); }
struct A { a: @int }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// Testing that calling fmt! (via info!) doesn't complain about impure borrows
+// Testing that calling fmt! (via info2!) doesn't complain about impure borrows
struct Big { b: @~str, c: uint, d: int, e: char,
f: float, g: bool }
f: 0.0,
g: true
};
- info!("test %?", a.b);
- info!("test %u", a.c);
- info!("test %i", a.d);
- info!("test %c", a.e);
- info!("test %f", a.f);
- info!("test %b", a.g);
+ info2!("test {:?}", a.b);
+ info2!("test {:u}", a.c);
+ info2!("test {:i}", a.d);
+ info2!("test {:c}", a.e);
+ info2!("test {:f}", a.f);
+ info2!("test {:b}", a.g);
}
pub fn main() {
fn something(f: &fn()) { f(); }
pub fn main() {
- something(|| error!("hi!") );
+ something(|| error2!("hi!") );
}
let x = @6;
let y = x.get();
- info!("y=%d", y);
+ info2!("y={}", y);
assert_eq!(y, 6);
let x = ~6;
let y = x.get();
- info!("y=%d", y);
+ info2!("y={}", y);
assert_eq!(y, 6);
let x = &6;
let y = x.get();
- info!("y=%d", y);
+ info2!("y={}", y);
assert_eq!(y, 6);
}
pub fn main() {
let x = ~[1, 2, 3];
let y = call_sum(x);
- info!("y==%d", y);
+ info2!("y=={}", y);
assert_eq!(y, 6);
let x = ~[1, 2, 3];
let y = x.sum_();
- info!("y==%d", y);
+ info2!("y=={}", y);
assert_eq!(y, 6);
let x = ~[1, 2, 3];
let y = x.sum_();
- info!("y==%d", y);
+ info2!("y=={}", y);
assert_eq!(y, 6);
}
let x = Outer {c8: 22u8, t: Inner {c64: 44u32}};
// Send it through the shape code
- let y = fmt!("%?", x);
+ let y = format!("{:?}", x);
- info!("align inner = %?", rusti::min_align_of::<Inner>());
- info!("size outer = %?", sys::size_of::<Outer>());
- info!("y = %s", y);
+ info2!("align inner = {:?}", rusti::min_align_of::<Inner>());
+ info2!("size outer = {:?}", sys::size_of::<Outer>());
+ info2!("y = {}", y);
// per clang/gcc the alignment of `inner` is 4 on x86.
assert_eq!(rusti::min_align_of::<Inner>(), m::align());
let x = Outer {c8: 22u8, t: Inner {c64: 44u64}};
// Send it through the shape code
- let y = fmt!("%?", x);
+ let y = format!("{:?}", x);
- info!("align inner = %?", rusti::min_align_of::<Inner>());
- info!("size outer = %?", sys::size_of::<Outer>());
- info!("y = %s", y);
+ info2!("align inner = {}", rusti::min_align_of::<Inner>());
+ info2!("size outer = {}", sys::size_of::<Outer>());
+ info2!("y = {}", y);
// per clang/gcc the alignment of `Inner` is 4 on x86.
assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
pub fn main() {
let x = X {foo: ~"hello", bar: ~"world"};
- info!(x.foo.clone());
- info!(x.bar.clone());
+ info2!("{}", x.foo.clone());
+ info2!("{}", x.bar.clone());
}
_sz: uint, _align: uint) -> bool { true }
fn visit_rec_field(&mut self, _i: uint, _name: &str,
_mtbl: uint, inner: *TyDesc) -> bool {
- error!("rec field!");
+ error2!("rec field!");
self.visit_inner(inner)
}
fn visit_leave_rec(&mut self, _n_fields: uint,
fn visit_enter_tup(&mut self, _n_fields: uint,
_sz: uint, _align: uint) -> bool { true }
fn visit_tup_field(&mut self, _i: uint, inner: *TyDesc) -> bool {
- error!("tup field!");
+ error2!("tup field!");
self.visit_inner(inner)
}
fn visit_leave_tup(&mut self, _n_fields: uint,
vals: ~[]});
let mut v = ptr_visit_adaptor(Inner {inner: u});
let td = get_tydesc_for(r);
- error!("tydesc sz: %u, align: %u",
+ error2!("tydesc sz: {}, align: {}",
(*td).size, (*td).align);
visit_tydesc(td, &mut v as &mut TyVisitor);
impl TyVisitor for MyVisitor {
fn visit_bot(&mut self) -> bool {
self.types.push(~"bot");
- error!("visited bot type");
+ error2!("visited bot type");
true
}
fn visit_nil(&mut self) -> bool {
self.types.push(~"nil");
- error!("visited nil type");
+ error2!("visited nil type");
true
}
fn visit_bool(&mut self) -> bool {
self.types.push(~"bool");
- error!("visited bool type");
+ error2!("visited bool type");
true
}
fn visit_int(&mut self) -> bool {
self.types.push(~"int");
- error!("visited int type");
+ error2!("visited int type");
true
}
fn visit_i8(&mut self) -> bool {
self.types.push(~"i8");
- error!("visited i8 type");
+ error2!("visited i8 type");
true
}
fn visit_i16(&mut self) -> bool {
self.types.push(~"i16");
- error!("visited i16 type");
+ error2!("visited i16 type");
true
}
fn visit_i32(&mut self) -> bool { true }
fn get_v6_a<'v>(a: &'v A, _i: uint) -> &'v int {
match a.value.v6 {
Some(ref v) => &v.f,
- None => fail!()
+ None => fail2!()
}
}
fn get_v6_b<'v>(a: &'v A, _i: uint) -> &'v int {
match *a {
A { value: B { v6: Some(ref v), _ } } => &v.f,
- _ => fail!()
+ _ => fail2!()
}
}
fn get_v6_c<'v>(a: &'v A, _i: uint) -> &'v int {
match a {
&A { value: B { v6: Some(ref v), _ } } => &v.f,
- _ => fail!()
+ _ => fail2!()
}
}
fn get<'r, T>(opt: &'r Option<T>) -> &'r T {
match *opt {
Some(ref v) => v,
- None => fail!("none")
+ None => fail2!("none")
}
}
pub fn main() {
let three = &3;
- error!(fmt!("%d", *f(three)));
+ error2!("{}", *f(three));
}
pub fn main() {
let p = @22u;
let r = foo(p);
- info!("r=%u", r);
+ info2!("r={}", r);
assert_eq!(r, 22u);
}
// A very limited test of the "bottom" region
-fn produce_static<T>() -> &'static T { fail!(); }
+fn produce_static<T>() -> &'static T { fail2!(); }
fn foo<T>(_x: &T) -> &uint { produce_static() }
pub fn main() {
let clam = Clam { chowder: &3 };
- info!(*clam.get_chowder());
+ info2!("{:?}", *clam.get_chowder());
clam.get_chowder();
}
match y {
int_wrapper_ctor(zz) => { z = zz; }
}
- info!(*z);
+ info2!("{:?}", *z);
}
let mut x: int = 3;
let y: &mut int = &mut x;
*y = 5;
- info!(*y);
+ info2!("{:?}", *y);
}
}
pub fn main() {
- let cl_box = box_it(|| info!("Hello, world!"));
+ let cl_box = box_it(|| info2!("Hello, world!"));
call_static_closure(cl_box);
}
let x = [ @[true], ..512 ];
let y = [ 0, ..1 ];
- error!("%?", x);
- error!("%?", y);
+ error2!("{:?}", x);
+ error2!("{:?}", y);
}
let a = r(i);
let b = (a, 10);
let (c, _d) = b;
- info!(c);
+ info2!("{:?}", c);
}
assert_eq!(*i, 1);
}
impl Drop for r {
fn drop(&mut self) {
unsafe {
- info!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
+ info2!("r's dtor: self = {:x}, self.v = {:x}, self.v's value = {:x}",
cast::transmute::<*mut r, uint>(self),
cast::transmute::<**int, uint>(&(self.v)),
cast::transmute::<*int, uint>(self.v));
next: None,
r: {
let rs = r(i1p);
- info!("r = %x", cast::transmute::<*r, uint>(&rs));
+ info2!("r = {:x}", cast::transmute::<*r, uint>(&rs));
rs }
});
- info!("x1 = %x, x1.r = %x",
+ info2!("x1 = {:x}, x1.r = {:x}",
cast::transmute::<@mut t, uint>(x1),
cast::transmute::<*r, uint>(&x1.r));
next: None,
r: {
let rs = r(i2p);
- info!("r2 = %x", cast::transmute::<*r, uint>(&rs));
+ info2!("r2 = {:x}", cast::transmute::<*r, uint>(&rs));
rs
}
});
- info!("x2 = %x, x2.r = %x",
+ info2!("x2 = {:x}, x2.r = {:x}",
cast::transmute::<@mut t, uint>(x2),
cast::transmute::<*r, uint>(&(x2.r)));
#[unsafe_destructor]
impl Drop for shrinky_pointer {
fn drop(&mut self) {
- error!(~"Hello!"); **(self.i) -= 1;
+ error2!("Hello!"); **(self.i) -= 1;
}
}
pub fn main() {
let my_total = @@mut 10;
{ let pt = shrinky_pointer(my_total); assert!((pt.look_at() == 10)); }
- error!("my_total = %d", **my_total);
+ error2!("my_total = {}", **my_total);
assert_eq!(**my_total, 9);
}
// -*- rust -*-
-fn my_err(s: ~str) -> ! { error!(s); fail!(); }
+fn my_err(s: ~str) -> ! { error2!("{:?}", s); fail2!(); }
fn okay(i: uint) -> int {
if i == 3u { my_err(~"I don't like three"); } else { return 42; }
#[start]
fn start(argc: int, argv: **u8) -> int {
do std::rt::start_on_main_thread(argc, argv) {
- info!("running on main thread");
+ info2!("running on main thread");
do spawn {
- info!("running on another thread");
+ info2!("running on another thread");
}
}
}
fn test05_start(f: &~fn(v: float, v: ~str) -> Pair<float, ~str>) {
let p = (*f)(22.22f, ~"Hi");
- info!(p.clone());
+ info2!("{:?}", p.clone());
assert!(p.a == 22.22f);
assert!(p.b == ~"Hi");
let q = (*f)(44.44f, ~"Ho");
- info!(q.clone());
+ info2!("{:?}", q.clone());
assert!(q.a == 44.44f);
assert!(q.b == ~"Ho");
}
fn test05() {
let three = ~3;
let fn_to_send: ~fn(int) = |n| {
- error!(*three + n); // will copy x into the closure
+ error2!("{}", *three + n); // will copy x into the closure
assert_eq!(*three, 3);
};
let fn_to_send = Cell::new(fn_to_send);
match none::<int> {
some::<int>(_) => {
for _i in c.iter() {
- info!(a);
+ info2!("{:?}", a);
let a = 17;
b.push(a);
}
let p_: Path_ = Path_ { global: true, idents: ~[~"hi"], types: ~[t] };
let p: path = Spanned { data: p_, span: sp };
let x = X { sp: sp, path: p };
- error!(x.path.clone());
- error!(x.clone());
+ error2!("{:?}", x.path.clone());
+ error2!("{:?}", x.clone());
}
-pub fn main() { let mut n; n = 1; info!(n); }
+pub fn main() { let mut n; n = 1; info2!("{}", n); }
pub fn main() {
let x = none::<int>;
- match x { none::<int> => { info!("hello world"); } }
+ match x { none::<int> => { info2!("hello world"); } }
}
fn uhoh<T>(v: ~[clam<T>]) {
match v[1] {
- a::<T>(ref _t, ref u) => { info!("incorrect"); info!(u); fail!(); }
- b::<T> => { info!("correct"); }
+ a::<T>(ref _t, ref u) => {
+ info2!("incorrect");
+ info2!("{:?}", u);
+ fail2!();
+ }
+ b::<T> => { info2!("correct"); }
}
}
use std::task;
fn x(s: ~str, n: int) {
- info!(s);
- info!(n);
+ info2!("{:?}", s);
+ info2!("{:?}", n);
}
pub fn main() {
task::spawn(|| x(~"hello from second spawned fn", 66) );
task::spawn(|| x(~"hello from third spawned fn", 67) );
let mut i: int = 30;
- while i > 0 { i = i - 1; info!("parent sleeping"); task::deschedule(); }
+ while i > 0 { i = i - 1; info2!("parent sleeping"); task::deschedule(); }
}
task::spawn(|| child(10) );
}
-fn child(i: int) { error!(i); assert!((i == 10)); }
+fn child(i: int) { error2!("{}", i); assert!((i == 10)); }
fn child(args: (int, int, int, int, int, int, int, int, int)) {
let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
- error!(i1);
- error!(i2);
- error!(i3);
- error!(i4);
- error!(i5);
- error!(i6);
- error!(i7);
- error!(i8);
- error!(i9);
+ error2!("{}", i1);
+ error2!("{}", i2);
+ error2!("{}", i3);
+ error2!("{}", i4);
+ error2!("{}", i5);
+ error2!("{}", i6);
+ error2!("{}", i7);
+ error2!("{}", i8);
+ error2!("{}", i9);
assert_eq!(i1, 10);
assert_eq!(i2, 20);
assert_eq!(i3, 30);
{
match io::file_writer(&path, [io::Create, io::Truncate]) {
- Err(ref e) => fail!(e.clone()),
+ Err(ref e) => fail2!("{}", e.clone()),
Ok(f) => {
for _ in range(0u, 1000) {
f.write_u8(0);
fn test1() {
let mut s: ~str = ~"hello";
s.push_str("world");
- info!(s.clone());
+ info2!("{}", s.clone());
assert_eq!(s[9], 'd' as u8);
}
let ff: ~str = ~"abc";
let a: ~str = ff + "ABC" + ff;
let b: ~str = ~"ABC" + ff + "ABC";
- info!(a.clone());
- info!(b.clone());
+ info2!("{}", a.clone());
+ info2!("{}", b.clone());
assert_eq!(a, ~"abcABCabc");
assert_eq!(b, ~"ABCabcABC");
}
let a: ~str = ~"hello";
let b: ~str = ~"world";
let s: ~str = a + b;
- info!(s.clone());
+ info2!("{}", s.clone());
assert_eq!(s[9], 'd' as u8);
}
pub fn main() {
let s = ~"hello";
let c: u8 = s[4];
- info!(c);
+ info2!("{:?}", c);
assert_eq!(c, 0x6f as u8);
}
let mut i = 20;
let mut expected_len = 1u;
while i > 0 {
- error!(a.len());
+ error2!("{}", a.len());
assert_eq!(a.len(), expected_len);
a = a + a; // FIXME(#3387)---can't write a += a
i -= 1;
impl Drop for foo {
fn drop(&mut self) {
- error!("%s", self.x);
+ error2!("{}", self.x);
}
}
c: 0xcccc_cccc_cccc_cccc_u64,
d: 0xdddd_dddd_dddd_dddd_u64 };
let qq = rustrt::rust_dbg_abi_1(q);
- error!("a: %x", qq.a as uint);
- error!("b: %x", qq.b as uint);
- error!("c: %x", qq.c as uint);
- error!("d: %x", qq.d as uint);
+ error2!("a: {:x}", qq.a as uint);
+ error2!("b: {:x}", qq.b as uint);
+ error2!("c: {:x}", qq.c as uint);
+ error2!("d: {:x}", qq.d as uint);
assert_eq!(qq.a, q.c + 1u64);
assert_eq!(qq.b, q.d - 1u64);
assert_eq!(qq.c, q.a + 1u64);
b: 0b_1010_1010_u8,
c: 1.0987654321e-15_f64 };
let ff = rustrt::rust_dbg_abi_2(f);
- error!("a: %f", ff.a as float);
- error!("b: %u", ff.b as uint);
- error!("c: %f", ff.c as float);
+ error2!("a: {}", ff.a as float);
+ error2!("b: {}", ff.b as uint);
+ error2!("c: {}", ff.c as float);
assert_eq!(ff.a, f.c + 1.0f64);
assert_eq!(ff.b, 0xff_u8);
assert_eq!(ff.c, f.a - 1.0f64);
pub fn main() {
let f = 1 as *libc::FILE;
- info!(f as int);
- info!(f as uint);
- info!(f as i8);
- info!(f as i16);
- info!(f as i32);
- info!(f as i64);
- info!(f as u8);
- info!(f as u16);
- info!(f as u32);
- info!(f as u64);
-
- info!(1 as int);
- info!(1 as uint);
- info!(1 as float);
- info!(1 as *libc::FILE);
- info!(1 as i8);
- info!(1 as i16);
- info!(1 as i32);
- info!(1 as i64);
- info!(1 as u8);
- info!(1 as u16);
- info!(1 as u32);
- info!(1 as u64);
- info!(1 as f32);
- info!(1 as f64);
-
- info!(1u as int);
- info!(1u as uint);
- info!(1u as float);
- info!(1u as *libc::FILE);
- info!(1u as i8);
- info!(1u as i16);
- info!(1u as i32);
- info!(1u as i64);
- info!(1u as u8);
- info!(1u as u16);
- info!(1u as u32);
- info!(1u as u64);
- info!(1u as f32);
- info!(1u as f64);
-
- info!(1i8 as int);
- info!(1i8 as uint);
- info!(1i8 as float);
- info!(1i8 as *libc::FILE);
- info!(1i8 as i8);
- info!(1i8 as i16);
- info!(1i8 as i32);
- info!(1i8 as i64);
- info!(1i8 as u8);
- info!(1i8 as u16);
- info!(1i8 as u32);
- info!(1i8 as u64);
- info!(1i8 as f32);
- info!(1i8 as f64);
-
- info!(1u8 as int);
- info!(1u8 as uint);
- info!(1u8 as float);
- info!(1u8 as *libc::FILE);
- info!(1u8 as i8);
- info!(1u8 as i16);
- info!(1u8 as i32);
- info!(1u8 as i64);
- info!(1u8 as u8);
- info!(1u8 as u16);
- info!(1u8 as u32);
- info!(1u8 as u64);
- info!(1u8 as f32);
- info!(1u8 as f64);
-
- info!(1i16 as int);
- info!(1i16 as uint);
- info!(1i16 as float);
- info!(1i16 as *libc::FILE);
- info!(1i16 as i8);
- info!(1i16 as i16);
- info!(1i16 as i32);
- info!(1i16 as i64);
- info!(1i16 as u8);
- info!(1i16 as u16);
- info!(1i16 as u32);
- info!(1i16 as u64);
- info!(1i16 as f32);
- info!(1i16 as f64);
-
- info!(1u16 as int);
- info!(1u16 as uint);
- info!(1u16 as float);
- info!(1u16 as *libc::FILE);
- info!(1u16 as i8);
- info!(1u16 as i16);
- info!(1u16 as i32);
- info!(1u16 as i64);
- info!(1u16 as u8);
- info!(1u16 as u16);
- info!(1u16 as u32);
- info!(1u16 as u64);
- info!(1u16 as f32);
- info!(1u16 as f64);
-
- info!(1i32 as int);
- info!(1i32 as uint);
- info!(1i32 as float);
- info!(1i32 as *libc::FILE);
- info!(1i32 as i8);
- info!(1i32 as i16);
- info!(1i32 as i32);
- info!(1i32 as i64);
- info!(1i32 as u8);
- info!(1i32 as u16);
- info!(1i32 as u32);
- info!(1i32 as u64);
- info!(1i32 as f32);
- info!(1i32 as f64);
-
- info!(1u32 as int);
- info!(1u32 as uint);
- info!(1u32 as float);
- info!(1u32 as *libc::FILE);
- info!(1u32 as i8);
- info!(1u32 as i16);
- info!(1u32 as i32);
- info!(1u32 as i64);
- info!(1u32 as u8);
- info!(1u32 as u16);
- info!(1u32 as u32);
- info!(1u32 as u64);
- info!(1u32 as f32);
- info!(1u32 as f64);
-
- info!(1i64 as int);
- info!(1i64 as uint);
- info!(1i64 as float);
- info!(1i64 as *libc::FILE);
- info!(1i64 as i8);
- info!(1i64 as i16);
- info!(1i64 as i32);
- info!(1i64 as i64);
- info!(1i64 as u8);
- info!(1i64 as u16);
- info!(1i64 as u32);
- info!(1i64 as u64);
- info!(1i64 as f32);
- info!(1i64 as f64);
-
- info!(1u64 as int);
- info!(1u64 as uint);
- info!(1u64 as float);
- info!(1u64 as *libc::FILE);
- info!(1u64 as i8);
- info!(1u64 as i16);
- info!(1u64 as i32);
- info!(1u64 as i64);
- info!(1u64 as u8);
- info!(1u64 as u16);
- info!(1u64 as u32);
- info!(1u64 as u64);
- info!(1u64 as f32);
- info!(1u64 as f64);
-
- info!(1u64 as int);
- info!(1u64 as uint);
- info!(1u64 as float);
- info!(1u64 as *libc::FILE);
- info!(1u64 as i8);
- info!(1u64 as i16);
- info!(1u64 as i32);
- info!(1u64 as i64);
- info!(1u64 as u8);
- info!(1u64 as u16);
- info!(1u64 as u32);
- info!(1u64 as u64);
- info!(1u64 as f32);
- info!(1u64 as f64);
-
- info!(true as int);
- info!(true as uint);
- info!(true as float);
- info!(true as *libc::FILE);
- info!(true as i8);
- info!(true as i16);
- info!(true as i32);
- info!(true as i64);
- info!(true as u8);
- info!(true as u16);
- info!(true as u32);
- info!(true as u64);
- info!(true as f32);
- info!(true as f64);
-
- info!(1. as int);
- info!(1. as uint);
- info!(1. as float);
- info!(1. as i8);
- info!(1. as i16);
- info!(1. as i32);
- info!(1. as i64);
- info!(1. as u8);
- info!(1. as u16);
- info!(1. as u32);
- info!(1. as u64);
- info!(1. as f32);
- info!(1. as f64);
-
- info!(1f32 as int);
- info!(1f32 as uint);
- info!(1f32 as float);
- info!(1f32 as i8);
- info!(1f32 as i16);
- info!(1f32 as i32);
- info!(1f32 as i64);
- info!(1f32 as u8);
- info!(1f32 as u16);
- info!(1f32 as u32);
- info!(1f32 as u64);
- info!(1f32 as f32);
- info!(1f32 as f64);
-
- info!(1f64 as int);
- info!(1f64 as uint);
- info!(1f64 as float);
- info!(1f64 as i8);
- info!(1f64 as i16);
- info!(1f64 as i32);
- info!(1f64 as i64);
- info!(1f64 as u8);
- info!(1f64 as u16);
- info!(1f64 as u32);
- info!(1f64 as u64);
- info!(1f64 as f32);
- info!(1f64 as f64);
+ info2!("{}", f as int);
+ info2!("{}", f as uint);
+ info2!("{}", f as i8);
+ info2!("{}", f as i16);
+ info2!("{}", f as i32);
+ info2!("{}", f as i64);
+ info2!("{}", f as u8);
+ info2!("{}", f as u16);
+ info2!("{}", f as u32);
+ info2!("{}", f as u64);
+
+ info2!("{}", 1 as int);
+ info2!("{}", 1 as uint);
+ info2!("{}", 1 as float);
+ info2!("{}", 1 as *libc::FILE);
+ info2!("{}", 1 as i8);
+ info2!("{}", 1 as i16);
+ info2!("{}", 1 as i32);
+ info2!("{}", 1 as i64);
+ info2!("{}", 1 as u8);
+ info2!("{}", 1 as u16);
+ info2!("{}", 1 as u32);
+ info2!("{}", 1 as u64);
+ info2!("{}", 1 as f32);
+ info2!("{}", 1 as f64);
+
+ info2!("{}", 1u as int);
+ info2!("{}", 1u as uint);
+ info2!("{}", 1u as float);
+ info2!("{}", 1u as *libc::FILE);
+ info2!("{}", 1u as i8);
+ info2!("{}", 1u as i16);
+ info2!("{}", 1u as i32);
+ info2!("{}", 1u as i64);
+ info2!("{}", 1u as u8);
+ info2!("{}", 1u as u16);
+ info2!("{}", 1u as u32);
+ info2!("{}", 1u as u64);
+ info2!("{}", 1u as f32);
+ info2!("{}", 1u as f64);
+
+ info2!("{}", 1i8 as int);
+ info2!("{}", 1i8 as uint);
+ info2!("{}", 1i8 as float);
+ info2!("{}", 1i8 as *libc::FILE);
+ info2!("{}", 1i8 as i8);
+ info2!("{}", 1i8 as i16);
+ info2!("{}", 1i8 as i32);
+ info2!("{}", 1i8 as i64);
+ info2!("{}", 1i8 as u8);
+ info2!("{}", 1i8 as u16);
+ info2!("{}", 1i8 as u32);
+ info2!("{}", 1i8 as u64);
+ info2!("{}", 1i8 as f32);
+ info2!("{}", 1i8 as f64);
+
+ info2!("{}", 1u8 as int);
+ info2!("{}", 1u8 as uint);
+ info2!("{}", 1u8 as float);
+ info2!("{}", 1u8 as *libc::FILE);
+ info2!("{}", 1u8 as i8);
+ info2!("{}", 1u8 as i16);
+ info2!("{}", 1u8 as i32);
+ info2!("{}", 1u8 as i64);
+ info2!("{}", 1u8 as u8);
+ info2!("{}", 1u8 as u16);
+ info2!("{}", 1u8 as u32);
+ info2!("{}", 1u8 as u64);
+ info2!("{}", 1u8 as f32);
+ info2!("{}", 1u8 as f64);
+
+ info2!("{}", 1i16 as int);
+ info2!("{}", 1i16 as uint);
+ info2!("{}", 1i16 as float);
+ info2!("{}", 1i16 as *libc::FILE);
+ info2!("{}", 1i16 as i8);
+ info2!("{}", 1i16 as i16);
+ info2!("{}", 1i16 as i32);
+ info2!("{}", 1i16 as i64);
+ info2!("{}", 1i16 as u8);
+ info2!("{}", 1i16 as u16);
+ info2!("{}", 1i16 as u32);
+ info2!("{}", 1i16 as u64);
+ info2!("{}", 1i16 as f32);
+ info2!("{}", 1i16 as f64);
+
+ info2!("{}", 1u16 as int);
+ info2!("{}", 1u16 as uint);
+ info2!("{}", 1u16 as float);
+ info2!("{}", 1u16 as *libc::FILE);
+ info2!("{}", 1u16 as i8);
+ info2!("{}", 1u16 as i16);
+ info2!("{}", 1u16 as i32);
+ info2!("{}", 1u16 as i64);
+ info2!("{}", 1u16 as u8);
+ info2!("{}", 1u16 as u16);
+ info2!("{}", 1u16 as u32);
+ info2!("{}", 1u16 as u64);
+ info2!("{}", 1u16 as f32);
+ info2!("{}", 1u16 as f64);
+
+ info2!("{}", 1i32 as int);
+ info2!("{}", 1i32 as uint);
+ info2!("{}", 1i32 as float);
+ info2!("{}", 1i32 as *libc::FILE);
+ info2!("{}", 1i32 as i8);
+ info2!("{}", 1i32 as i16);
+ info2!("{}", 1i32 as i32);
+ info2!("{}", 1i32 as i64);
+ info2!("{}", 1i32 as u8);
+ info2!("{}", 1i32 as u16);
+ info2!("{}", 1i32 as u32);
+ info2!("{}", 1i32 as u64);
+ info2!("{}", 1i32 as f32);
+ info2!("{}", 1i32 as f64);
+
+ info2!("{}", 1u32 as int);
+ info2!("{}", 1u32 as uint);
+ info2!("{}", 1u32 as float);
+ info2!("{}", 1u32 as *libc::FILE);
+ info2!("{}", 1u32 as i8);
+ info2!("{}", 1u32 as i16);
+ info2!("{}", 1u32 as i32);
+ info2!("{}", 1u32 as i64);
+ info2!("{}", 1u32 as u8);
+ info2!("{}", 1u32 as u16);
+ info2!("{}", 1u32 as u32);
+ info2!("{}", 1u32 as u64);
+ info2!("{}", 1u32 as f32);
+ info2!("{}", 1u32 as f64);
+
+ info2!("{}", 1i64 as int);
+ info2!("{}", 1i64 as uint);
+ info2!("{}", 1i64 as float);
+ info2!("{}", 1i64 as *libc::FILE);
+ info2!("{}", 1i64 as i8);
+ info2!("{}", 1i64 as i16);
+ info2!("{}", 1i64 as i32);
+ info2!("{}", 1i64 as i64);
+ info2!("{}", 1i64 as u8);
+ info2!("{}", 1i64 as u16);
+ info2!("{}", 1i64 as u32);
+ info2!("{}", 1i64 as u64);
+ info2!("{}", 1i64 as f32);
+ info2!("{}", 1i64 as f64);
+
+ info2!("{}", 1u64 as int);
+ info2!("{}", 1u64 as uint);
+ info2!("{}", 1u64 as float);
+ info2!("{}", 1u64 as *libc::FILE);
+ info2!("{}", 1u64 as i8);
+ info2!("{}", 1u64 as i16);
+ info2!("{}", 1u64 as i32);
+ info2!("{}", 1u64 as i64);
+ info2!("{}", 1u64 as u8);
+ info2!("{}", 1u64 as u16);
+ info2!("{}", 1u64 as u32);
+ info2!("{}", 1u64 as u64);
+ info2!("{}", 1u64 as f32);
+ info2!("{}", 1u64 as f64);
+
+ info2!("{}", 1u64 as int);
+ info2!("{}", 1u64 as uint);
+ info2!("{}", 1u64 as float);
+ info2!("{}", 1u64 as *libc::FILE);
+ info2!("{}", 1u64 as i8);
+ info2!("{}", 1u64 as i16);
+ info2!("{}", 1u64 as i32);
+ info2!("{}", 1u64 as i64);
+ info2!("{}", 1u64 as u8);
+ info2!("{}", 1u64 as u16);
+ info2!("{}", 1u64 as u32);
+ info2!("{}", 1u64 as u64);
+ info2!("{}", 1u64 as f32);
+ info2!("{}", 1u64 as f64);
+
+ info2!("{}", true as int);
+ info2!("{}", true as uint);
+ info2!("{}", true as float);
+ info2!("{}", true as *libc::FILE);
+ info2!("{}", true as i8);
+ info2!("{}", true as i16);
+ info2!("{}", true as i32);
+ info2!("{}", true as i64);
+ info2!("{}", true as u8);
+ info2!("{}", true as u16);
+ info2!("{}", true as u32);
+ info2!("{}", true as u64);
+ info2!("{}", true as f32);
+ info2!("{}", true as f64);
+
+ info2!("{}", 1. as int);
+ info2!("{}", 1. as uint);
+ info2!("{}", 1. as float);
+ info2!("{}", 1. as i8);
+ info2!("{}", 1. as i16);
+ info2!("{}", 1. as i32);
+ info2!("{}", 1. as i64);
+ info2!("{}", 1. as u8);
+ info2!("{}", 1. as u16);
+ info2!("{}", 1. as u32);
+ info2!("{}", 1. as u64);
+ info2!("{}", 1. as f32);
+ info2!("{}", 1. as f64);
+
+ info2!("{}", 1f32 as int);
+ info2!("{}", 1f32 as uint);
+ info2!("{}", 1f32 as float);
+ info2!("{}", 1f32 as i8);
+ info2!("{}", 1f32 as i16);
+ info2!("{}", 1f32 as i32);
+ info2!("{}", 1f32 as i64);
+ info2!("{}", 1f32 as u8);
+ info2!("{}", 1f32 as u16);
+ info2!("{}", 1f32 as u32);
+ info2!("{}", 1f32 as u64);
+ info2!("{}", 1f32 as f32);
+ info2!("{}", 1f32 as f64);
+
+ info2!("{}", 1f64 as int);
+ info2!("{}", 1f64 as uint);
+ info2!("{}", 1f64 as float);
+ info2!("{}", 1f64 as i8);
+ info2!("{}", 1f64 as i16);
+ info2!("{}", 1f64 as i32);
+ info2!("{}", 1f64 as i64);
+ info2!("{}", 1f64 as u8);
+ info2!("{}", 1f64 as u16);
+ info2!("{}", 1f64 as u32);
+ info2!("{}", 1f64 as u64);
+ info2!("{}", 1f64 as f32);
+ info2!("{}", 1f64 as f64);
}
fn main() {
// check
- if ! cfg!(foo) { fail!() }
- if cfg!(not(foo)) { fail!() }
+ if ! cfg!(foo) { fail2!() }
+ if cfg!(not(foo)) { fail2!() }
- if ! cfg!(bar(baz)) { fail!() }
- if cfg!(not(bar(baz))) { fail!() }
+ if ! cfg!(bar(baz)) { fail2!() }
+ if cfg!(not(bar(baz))) { fail2!() }
- if ! cfg!(qux="foo") { fail!() }
- if cfg!(not(qux="foo")) { fail!() }
+ if ! cfg!(qux="foo") { fail2!() }
+ if cfg!(not(qux="foo")) { fail2!() }
- if ! cfg!(foo, bar(baz), qux="foo") { fail!() }
- if cfg!(not(foo, bar(baz), qux="foo")) { fail!() }
+ if ! cfg!(foo, bar(baz), qux="foo") { fail2!() }
+ if cfg!(not(foo, bar(baz), qux="foo")) { fail2!() }
- if cfg!(not_a_cfg) { fail!() }
- if cfg!(not_a_cfg, foo, bar(baz), qux="foo") { fail!() }
+ if cfg!(not_a_cfg) { fail2!() }
+ if cfg!(not_a_cfg, foo, bar(baz), qux="foo") { fail2!() }
- if ! cfg!(not(not_a_cfg)) { fail!() }
- if ! cfg!(not(not_a_cfg), foo, bar(baz), qux="foo") { fail!() }
+ if ! cfg!(not(not_a_cfg)) { fail2!() }
+ if ! cfg!(not(not_a_cfg), foo, bar(baz), qux="foo") { fail2!() }
- if cfg!(trailing_comma, ) { fail!() }
+ if cfg!(trailing_comma, ) { fail2!() }
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-flags: --cfg nofmt
+
extern mod extra;
+macro_rules! fmt(($($arg:tt)*) => (oldfmt!($($arg)*)))
+
fn test(actual: ~str, expected: ~str) {
- info!(actual.clone());
- info!(expected.clone());
+ info2!("{}", actual.clone());
+ info2!("{}", expected.clone());
assert_eq!(actual, expected);
}
{
assert!(file!().ends_with("includeme.fragment"));
assert!(line!() == 5u);
- fmt!("victory robot %u", line!())
+ format!("victory robot {}", line!())
}
pub fn main() {
let x = t_rec {c8: 22u8, t: a_tag(44u64)};
- let y = fmt!("%?", x);
- info!("y = %s", y);
+ let y = format!("{:?}", x);
+ info2!("y = {}", y);
assert_eq!(y, ~"t_rec{c8: 22u8, t: a_tag(44u64)}");
}
}
pub fn main() {
- let act = fmt!("%?", red);
+ let act = format!("{:?}", red);
println(act);
assert_eq!(~"red", act);
- assert_eq!(~"green", fmt!("%?", green));
- assert_eq!(~"white", fmt!("%?", white));
+ assert_eq!(~"green", format!("{:?}", green));
+ assert_eq!(~"white", format!("{:?}", white));
}
pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }
fn evenk(n: int, k: extern fn(bool) -> bool) -> bool {
- info!("evenk");
- info!(n);
+ info2!("evenk");
+ info2!("{:?}", n);
if n == 0 { return k(true); } else { return oddk(n - 1, k); }
}
fn oddk(n: int, k: extern fn(bool) -> bool) -> bool {
- info!("oddk");
- info!(n);
+ info2!("oddk");
+ info2!("{:?}", n);
if n == 0 { return k(false); } else { return evenk(n - 1, k); }
}
fn test05_start(ch : &Chan<int>) {
ch.send(10);
- error!("sent 10");
+ error2!("sent 10");
ch.send(20);
- error!("sent 20");
+ error2!("sent 20");
ch.send(30);
- error!("sent 30");
+ error2!("sent 30");
}
fn test05() {
let (po, ch) = comm::stream();
task::spawn(|| test05_start(&ch) );
let mut value: int = po.recv();
- error!(value);
+ error2!("{}", value);
value = po.recv();
- error!(value);
+ error2!("{}", value);
value = po.recv();
- error!(value);
+ error2!("{}", value);
assert_eq!(value, 30);
}
pub fn main() { test00(); }
-fn start() { info!("Started / Finished task."); }
+fn start() { info2!("Started / Finished task."); }
fn test00() {
task::try(|| start() );
- info!("Completing.");
+ info2!("Completing.");
}
let mut b;
a = p.recv();
assert!(a == ~"A");
- error!(a);
+ error2!("{:?}", a);
b = p.recv();
assert!(b == ~"B");
- error!(b);
+ error2!("{:?}", b);
}
pub fn main() {
pub fn main() { test00(); }
-fn start(_task_number: int) { info!("Started / Finished task."); }
+fn start(_task_number: int) { info2!("Started / Finished task."); }
fn test00() {
let i: int = 0;
// Try joining tasks that have already finished.
result.unwrap().recv();
- info!("Joined task.");
+ info2!("Joined task.");
}
}
pub fn main() {
- info!("Check that we don't deadlock.");
+ info2!("Check that we don't deadlock.");
let (_p, ch) = comm::stream();
task::try(|| start(&ch, 0, 10) );
- info!("Joined task");
+ info2!("Joined task");
}
// Spawn 10 tasks each sending us back one int.
let mut i = 10;
while (i > 0) {
- info!(i);
+ info2!("{}", i);
let ch = ch.clone();
task::spawn({let i = i; || child(i, &ch)});
i = i - 1;
i = 10;
while (i > 0) {
- info!(i);
+ info2!("{}", i);
po.recv();
i = i - 1;
}
- info!("main thread exiting");
+ info2!("main thread exiting");
}
fn child(x: int, ch: &comm::SharedChan<int>) {
- info!(x);
+ info2!("{}", x);
ch.send(x);
}
use std::comm;
use std::task;
-pub fn main() { info!("===== WITHOUT THREADS ====="); test00(); }
+pub fn main() { info2!("===== WITHOUT THREADS ====="); test00(); }
fn test00_start(ch: &SharedChan<int>, message: int, count: int) {
- info!("Starting test00_start");
+ info2!("Starting test00_start");
let mut i: int = 0;
while i < count {
- info!("Sending Message");
+ info2!("Sending Message");
ch.send(message + 0);
i = i + 1;
}
- info!("Ending test00_start");
+ info2!("Ending test00_start");
}
fn test00() {
let number_of_tasks: int = 16;
let number_of_messages: int = 4;
- info!("Creating tasks");
+ info2!("Creating tasks");
let (po, ch) = comm::stream();
let ch = comm::SharedChan::new(ch);
// Join spawned tasks...
for r in results.iter() { r.recv(); }
- info!("Completed: Final number is: ");
- error!(sum);
+ info2!("Completed: Final number is: ");
+ error2!("{:?}", sum);
// assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
// number_of_messages));
assert_eq!(sum, 480);
c.send(4);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
c.send(5);
c.send(6);
c.send(7);
c.send(8);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
r = p.recv();
sum += r;
- info!(r);
+ info2!("{}", r);
assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
}
let mut i: int = 0;
while i < number_of_messages {
sum += p.recv();
- info!(r);
+ info2!("{:?}", r);
i += 1;
}
// to depend on std
fn recursive_mkdir_rel() {
let path = Path("frob");
- debug!("recursive_mkdir_rel: Making: %s in cwd %s [%?]", path.to_str(),
+ debug2!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.to_str(),
os::getcwd().to_str(),
os::path_exists(&path));
assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
fn recursive_mkdir_rel_2() {
let path = Path("./frob/baz");
- debug!("recursive_mkdir_rel_2: Making: %s in cwd %s [%?]", path.to_str(),
+ debug2!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.to_str(),
os::getcwd().to_str(), os::path_exists(&path));
assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
assert!(os::path_is_dir(&path));
assert!(os::path_is_dir(&path.pop()));
let path2 = Path("quux/blat");
- debug!("recursive_mkdir_rel_2: Making: %s in cwd %s", path2.to_str(),
+ debug2!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.to_str(),
os::getcwd().to_str());
assert!(os::mkdir_recursive(&path2, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
assert!(os::path_is_dir(&path2));
couldn't create temp dir");
let root = tmpdir.push("foo");
- debug!("making %s", root.to_str());
+ debug2!("making {}", root.to_str());
assert!(os::make_dir(&root, rwx));
assert!(os::make_dir(&root.push("foo"), rwx));
assert!(os::make_dir(&root.push("foo").push("bar"), rwx));
fn test_ret() { let _x: @int = return; }
fn test_fail() {
- fn f() { let _x: @int = fail!(); }
+ fn f() { let _x: @int = fail2!(); }
task::try(|| f() );
}
fn test_fail_indirect() {
- fn f() -> ! { fail!(); }
+ fn f() -> ! { fail2!(); }
fn g() { let _x: @int = f(); }
task::try(|| g() );
}
// Building as a test runner means that a synthetic main will be run,
// not ours
-pub fn main() { fail!(); }
+pub fn main() { fail2!(); }
pub fn main() {
let mut i = 10;
while i > 0 { task::spawn({let i = i; || child(i)}); i = i - 1; }
- info!("main thread exiting");
+ info2!("main thread exiting");
}
-fn child(x: int) { info!(x); }
+fn child(x: int) { info2!("{}", x); }
fn to_str_(&self) -> ~str {
let (l, r) = (self.left, self.right);
let val = &self.val;
- fmt!("[%s, %s, %s]", val.to_str_(), l.to_str_(), r.to_str_())
+ format!("[{}, {}, {}]", val.to_str_(), l.to_str_(), r.to_str_())
}
}
impl<T:to_str> to_str for ~[T] {
fn to_string(&self) -> ~str {
- fmt!("[%s]", self.iter().map(|e| e.to_string()).collect::<~[~str]>().connect(", "))
+ format!("[{}]", self.iter().map(|e| e.to_string()).to_owned_vec().connect(", "))
}
}
trait Foo {
fn bar(&self) -> ~str {
- fmt!("test")
+ format!("test")
}
}
let (po, ch) = comm::stream();
ch.send(42);
let r = po.recv();
- error!(r);
+ error2!("{:?}", r);
}
match (a, b) {
(A(x), A(y)) => A($e),
(B(x), B(y)) => B($e),
- _ => fail!()
+ _ => fail2!()
}
}
)
assert!(!Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(magenta))));
- error!("Assertions all succeeded!");
+ error2!("Assertions all succeeded!");
}
assert!(!branch(@leaf(magenta), @leaf(cyan))
.isEq(branch(@leaf(magenta), @leaf(magenta))));
- error!("Assertions all succeeded!");
+ error2!("Assertions all succeeded!");
}
pub fn main() {
let a = 1;
let a_neg: i8 = -a;
- error!(a_neg);
+ error2!("{}", a_neg);
let b = 1;
let b_neg: i16 = -b;
- error!(b_neg);
+ error2!("{}", b_neg);
let c = 1;
let c_neg: i32 = -c;
- error!(c_neg);
+ error2!("{}", c_neg);
let d = 1;
let d_neg: i64 = -d;
- error!(d_neg);
+ error2!("{}", d_neg);
let e = 1;
let e_neg: int = -e;
- error!(e_neg);
+ error2!("{}", e_neg);
// intentional overflows
let f = 1;
let f_neg: u8 = -f;
- error!(f_neg);
+ error2!("{}", f_neg);
let g = 1;
let g_neg: u16 = -g;
- error!(g_neg);
+ error2!("{}", g_neg);
let h = 1;
let h_neg: u32 = -h;
- error!(h_neg);
+ error2!("{}", h_neg);
let i = 1;
let i_neg: u64 = -i;
- error!(i_neg);
+ error2!("{}", i_neg);
let j = 1;
let j_neg: uint = -j;
- error!(j_neg);
+ error2!("{}", j_neg);
}
let rc1 = sys::refcount(*i);
let j = i.clone();
let rc2 = sys::refcount(*i);
- error!("rc1: %u rc2: %u", rc1, rc2);
+ error2!("rc1: {} rc2: {}", rc1, rc2);
assert_eq!(rc1 + 1u, rc2);
}
}
fn f(_i: ~int) -> ~int {
- fail!();
+ fail2!();
}
let x = u(~10);
assert!(match x {
u(a) => {
- error!(a);
+ error2!("{:?}", a);
*a
}
_ => { 66 }
pub fn main() {
let i = ~100;
- error!(i);
+ error2!("{:?}", i);
}
pub fn main() {
assert!(match u(~10) {
u(a) => {
- error!(a);
+ error2!("{:?}", a);
*a
}
_ => { 66 }
fn simple() {
match ~true {
~true => { }
- _ => { fail!(); }
+ _ => { fail2!(); }
}
}
impl Drop for Foo {
fn drop(&mut self) {
- fail!("This failure should happen.");
+ fail2!("This failure should happen.");
}
}
fn id(x: bool) -> bool { x }
fn call_id() {
- let c = fail!();
+ let c = fail2!();
id(c); //~ WARNING unreachable statement
}
fn id(x: bool) -> bool { x }
fn call_id() {
- let c = fail!();
+ let c = fail2!();
id(c);
}
fn f() {
let _a = @0;
- fail!();
+ fail2!();
}
pub fn main() {
impl Drop for complainer {
fn drop(&mut self) {
- error!("About to send!");
+ error2!("About to send!");
self.c.send(true);
- error!("Sent!");
+ error2!("Sent!");
}
}
fn complainer(c: SharedChan<bool>) -> complainer {
- error!("Hello!");
+ error2!("Hello!");
complainer {
c: c
}
fn f(c: SharedChan<bool>) {
let _c = complainer(c);
- fail!();
+ fail2!();
}
pub fn main() {
let (p, c) = stream();
let c = SharedChan::new(c);
task::spawn_unlinked(|| f(c.clone()) );
- error!("hiiiiiiiii");
+ error2!("hiiiiiiiii");
assert!(p.recv());
}
fn f() {
let _c = complainer(@0);
- fail!();
+ fail2!();
}
pub fn main() {
fn f() {
let _a = ~0;
- fail!();
+ fail2!();
}
pub fn main() {
enum myoption<T> { none, some(T), }
-pub fn main() { info!(5); }
+pub fn main() { info2!("{}", 5); }
fn foo<T>(o: myoption<T>) -> int {
let mut x: int;
match o {
- none::<T> => { fail!(); }
+ none::<T> => { fail2!(); }
some::<T>(_t) => { x = 5; }
}
return x;
enum myoption<T> { none, some(T), }
-pub fn main() { info!(5); }
+pub fn main() { info2!("{}", 5); }
fn check_str_eq(a: ~str, b: ~str) {
let mut i: int = 0;
for ab in a.byte_iter() {
- info!(i);
- info!(ab);
+ info2!("{}", i);
+ info2!("{}", ab);
let bb: u8 = b[i];
- info!(bb);
+ info2!("{}", bb);
assert_eq!(ab, bb);
i += 1;
}
let a: ~[int] = ~[1, 2, 3, 4, 5];
let b: ~[int] = ~[6, 7, 8, 9, 0];
let v: ~[int] = a + b;
- info!(v[9]);
+ info2!("{}", v[9]);
assert_eq!(v[0], 1);
assert_eq!(v[7], 8);
assert_eq!(v[9], 0);
pub fn main() {
let mut later: ~[int];
if true { later = ~[1]; } else { later = ~[2]; }
- info!(later[0]);
+ info2!("{}", later[0]);
}
pub fn main() {
let x = @[1, 2, 3];
match x {
- [2, .._] => fail!(),
+ [2, .._] => fail2!(),
[1, ..tail] => {
assert_eq!(tail, [2, 3]);
}
- [_] => fail!(),
- [] => fail!()
+ [_] => fail2!(),
+ [] => fail2!()
}
let y = (~[(1, true), (2, false)], 0.5);
match y {
- ([_, _, _], 0.5) => fail!(),
+ ([_, _, _], 0.5) => fail2!(),
([(1, a), (b, false), ..tail], _) => {
assert_eq!(a, true);
assert_eq!(b, 2);
assert!(tail.is_empty());
}
- ([.._tail], _) => fail!()
+ ([.._tail], _) => fail2!()
}
}
fn a() {
let x = ~[1];
match x {
- [_, _, _, _, _, .._] => fail!(),
- [.._, _, _, _, _] => fail!(),
- [_, .._, _, _] => fail!(),
- [_, _] => fail!(),
+ [_, _, _, _, _, .._] => fail2!(),
+ [.._, _, _, _, _] => fail2!(),
+ [_, .._, _, _] => fail2!(),
+ [_, _] => fail2!(),
[a] => {
assert_eq!(a, 1);
}
- [] => fail!()
+ [] => fail2!()
}
}
assert_eq!(b, 2);
assert_eq!(c, &[3]);
}
- _ => fail!()
+ _ => fail2!()
}
match x {
[..a, b, c] => {
assert_eq!(b, 2);
assert_eq!(c, 3);
}
- _ => fail!()
+ _ => fail2!()
}
match x {
[a, ..b, c] => {
assert_eq!(b, &[2]);
assert_eq!(c, 3);
}
- _ => fail!()
+ _ => fail2!()
}
match x {
[a, b, c] => {
assert_eq!(b, 2);
assert_eq!(c, 3);
}
- _ => fail!()
+ _ => fail2!()
}
}
fn c() {
let x = [1];
match x {
- [2, .. _] => fail!(),
+ [2, .. _] => fail2!(),
[.. _] => ()
}
}
let mut i = 20;
let mut expected_len = 1u;
while i > 0 {
- error!(a.len());
+ error2!("{}", a.len());
assert_eq!(a.len(), expected_len);
a = a + a; // FIXME(#3387)---can't write a += a
i -= 1;
fn p() -> bool { true }
let _a = (assert!((true)) == (assert!(p())));
let _c = (assert!((p())) == ());
- let _b: bool = (info!("%d", 0) == (return 0u));
+ let _b: bool = (info2!("{}", 0) == (return 0u));
}
fn angrydome() {
loop { if break { } }
let mut i = 0;
- loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => fail!("wat") } }
+ loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => fail2!("wat") } }
break; }
}
-fn evil_lincoln() { let _evil = info!("lincoln"); }
+fn evil_lincoln() { let _evil = info2!("lincoln"); }
pub fn main() {
strange();
let mut i = 1;
while i > 0 {
assert!((i > 0));
- info!(i);
+ info2!("{}", i);
i -= 1;
continue;
}
while z < 50 {
z += 1;
while false { x = y; y = z; }
- info!(y);
+ info2!("{}", y);
}
assert!((y == 42 && z == 50));
}
pub fn main() {
let mut i: int = 90;
while i < 100 {
- info!(i);
+ info2!("{}", i);
i = i + 1;
if i == 95 {
let _v: ~[int] =
~[1, 2, 3, 4, 5]; // we check that it is freed by break
- info!("breaking");
+ info2!("breaking");
break;
}
}
pub fn main() {
let mut x: int = 10;
let mut y: int = 0;
- while y < x { info!(y); info!("hello"); y = y + 1; }
+ while y < x { info2!("{}", y); info2!("hello"); y = y + 1; }
while x > 0 {
- info!("goodbye");
+ info2!("goodbye");
x = x - 1;
- info!(x);
+ info2!("{}", x);
}
}
Some(ref z) if z.with(|b| *b) => {
do z.with |b| { assert!(*b); }
},
- _ => fail!()
+ _ => fail2!()
}
}
}
let mut builder = task::task();
builder.future_result(|r| { result = Some(r); });
builder.spawn(child);
- error!("1");
+ error2!("1");
task::deschedule();
- error!("2");
+ error2!("2");
task::deschedule();
- error!("3");
+ error2!("3");
result.unwrap().recv();
}
fn child() {
- error!("4"); task::deschedule(); error!("5"); task::deschedule(); error!("6");
+ error2!("4"); task::deschedule(); error2!("5"); task::deschedule(); error2!("6");
}
let mut builder = task::task();
builder.future_result(|r| { result = Some(r); });
builder.spawn(child);
- error!("1");
+ error2!("1");
task::deschedule();
result.unwrap().recv();
}
-fn child() { error!("2"); }
+fn child() { error2!("2"); }
pub fn main() {
let mut i: int = 0;
- while i < 100 { i = i + 1; error!(i); task::deschedule(); }
+ while i < 100 { i = i + 1; error2!("{}", i); task::deschedule(); }
}