1
Fork 0

Change 'print(fmt!(...))' to printf!/printfln! in src/test/

This commit is contained in:
Birunthan Mohanathas 2013-07-22 19:04:51 +03:00 committed by Daniel Micay
parent d047cf1ec6
commit 206ae5752e
63 changed files with 98 additions and 102 deletions

View file

@ -24,7 +24,7 @@ fn timed(label: &str, f: &fn()) {
let start = time::precise_time_s();
f();
let end = time::precise_time_s();
io::println(fmt!(" %s: %f", label, end - start));
printfln!(" %s: %f", label, end - start);
}
fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
@ -116,7 +116,7 @@ fn main() {
}
}
io::println(fmt!("%? keys", n_keys));
printfln!("%? keys", n_keys);
io::println("\nTreeMap:");

View file

@ -58,7 +58,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) {
test();
let stop = precise_time_s();
io::println(fmt!("%s:\t\t%f ms", name, (stop - start) * 1000f));
printfln!("%s:\t\t%f ms", name, (stop - start) * 1000f);
}
fn shift_push() {

View file

@ -119,8 +119,7 @@ fn main() {
let elapsed = (stop - start);
let rate = (num_msgs as float) / elapsed;
io::println(fmt!("Sent %? messages in %? seconds",
num_msgs, elapsed));
io::println(fmt!(" %? messages / second", rate));
io::println(fmt!(" %? μs / message", 1000000. / rate));
printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
printfln!(" %? messages / second", rate);
printfln!(" %? μs / message", 1000000. / rate);
}

View file

@ -105,8 +105,7 @@ fn main() {
let elapsed = (stop - start);
let rate = (num_msgs as float) / elapsed;
io::println(fmt!("Sent %? messages in %? seconds",
num_msgs, elapsed));
io::println(fmt!(" %? messages / second", rate));
io::println(fmt!(" %? μs / message", 1000000. / rate));
printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
printfln!(" %? messages / second", rate);
printfln!(" %? μs / message", 1000000. / rate);
}

View file

@ -115,8 +115,7 @@ fn main() {
let elapsed = (stop - start);
let rate = (num_msgs as float) / elapsed;
io::println(fmt!("Sent %? messages in %? seconds",
num_msgs, elapsed));
io::println(fmt!(" %? messages / second", rate));
io::println(fmt!(" %? μs / message", 1000000. / rate));
printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
printfln!(" %? messages / second", rate);
printfln!(" %? μs / message", 1000000. / rate);
}

View file

@ -198,13 +198,13 @@ fn main() {
let bounded = do timeit { bounded(count) };
let unbounded = do timeit { unbounded(count) };
io::println(fmt!("count: %?\n", count));
io::println(fmt!("bounded: %? s\t(%? μs/message)",
bounded, bounded * 1000000. / (count as float)));
io::println(fmt!("unbounded: %? s\t(%? μs/message)",
unbounded, unbounded * 1000000. / (count as float)));
printfln!("count: %?\n", count);
printfln!("bounded: %? s\t(%? μs/message)",
bounded, bounded * 1000000. / (count as float));
printfln!("unbounded: %? s\t(%? μs/message)",
unbounded, unbounded * 1000000. / (count as float));
io::println(fmt!("\n\
printfln!("\n\
bounded is %?%% faster",
(unbounded - bounded) / bounded * 100.));
(unbounded - bounded) / bounded * 100.);
}

View file

@ -36,5 +36,5 @@ fn main() {
args
};
let n = int::from_str(args[1]).get();
io::println(fmt!("Ack(3,%d): %d\n", n, ack(3, n)));
printfln!("Ack(3,%d): %d\n", n, ack(3, n));
}

View file

@ -61,9 +61,9 @@ fn main() {
let stretch_depth = max_depth + 1;
let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth);
println(fmt!("stretch tree of depth %d\t check: %d",
printfln!("stretch tree of depth %d\t check: %d",
stretch_depth,
item_check(stretch_tree)));
item_check(stretch_tree));
let long_lived_arena = arena::Arena();
let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
@ -79,12 +79,11 @@ fn main() {
chk += item_check(temp_tree);
i += 1;
}
println(fmt!("%d\t trees of depth %d\t check: %d",
iterations * 2, depth,
chk));
printfln!("%d\t trees of depth %d\t check: %d",
iterations * 2, depth, chk));
depth += 2;
}
println(fmt!("long lived tree of depth %d\t check: %d",
printfln!("long lived tree of depth %d\t check: %d",
max_depth,
item_check(long_lived_tree)));
item_check(long_lived_tree));
}

View file

@ -93,5 +93,5 @@ fn fannkuch_redux(n: i32) -> i32 {
#[fixed_stack_segment]
fn main() {
let n: i32 = FromStr::from_str(os::args()[1]).get();
println(fmt!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int));
printfln!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int);
}

View file

@ -32,5 +32,5 @@ fn main() {
args
};
let n = int::from_str(args[1]).get();
io::println(fmt!("%d\n", fib(n)));
printfln!("%d\n", fib(n));
}

View file

@ -82,7 +82,7 @@ struct PrintCallback(&'static str);
impl TableCallback for PrintCallback {
fn f(&self, entry: &mut Entry) {
println(fmt!("%d\t%s", entry.count as int, **self));
printfln!("%d\t%s", entry.count as int, **self);
}
}
@ -279,9 +279,9 @@ fn print_frequencies(frequencies: &Table, frame: i32) {
}
for vector.each |&(key, count)| {
println(fmt!("%s %.3f",
printfln!("%s %.3f",
key.unpack(frame),
(count as float * 100.0) / (total_count as float)));
(count as float * 100.0) / (total_count as float));
}
}

View file

@ -15,7 +15,7 @@ fn main() {
let mut byte_acc: i8 = 0;
let mut bit_num: i32 = 0;
println(fmt!("P4\n%d %d", w as int, h as int));
printfln!("P4\n%d %d", w as int, h as int);
let mode = "w";
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));

View file

@ -142,9 +142,9 @@ fn main() {
let mut bodies = BODIES;
offset_momentum(&mut bodies);
println(fmt!("%.9f", energy(&bodies) as float));
printfln!("%.9f", energy(&bodies) as float);
advance(&mut bodies, 0.01, n);
println(fmt!("%.9f", energy(&bodies) as float));
printfln!("%.9f", energy(&bodies) as float);
}

View file

@ -61,5 +61,5 @@ fn main() {
mult_AtAv(v, u, tmp);
}
println(fmt!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float));
printfln!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float);
}

View file

@ -40,7 +40,7 @@ fn roundtrip(id: int, n_tasks: int, p: &Port<int>, ch: &Chan<int>) {
while (true) {
match p.recv() {
1 => {
println(fmt!("%d\n", id));
printfln!("%d\n", id);
return;
}
token => {

View file

@ -18,7 +18,7 @@ struct Foo {
impl Foo {
pub fn printme(&mut self) {
io::println(fmt!("%d", self.x));
printfln!("%d", self.x);
}
}

View file

@ -9,5 +9,5 @@ fn a() -> &int {
fn main() {
let fifth = a();
println(fmt!("%d", *fifth));
printfln!("%d", *fifth);
}

View file

@ -22,5 +22,5 @@ fn main() {
let u = Thing {x: 2};
let _v = u.mul(&3); // This is ok
let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
println(fmt!("%i", w.x));
printfln!("%i", w.x);
}

View file

@ -14,5 +14,5 @@ fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cann
fn main() {
let v = &5;
println(fmt!("%d", f(v)()));
printfln!("%d", f(v)());
}

View file

@ -28,7 +28,7 @@ fn innocent_looking_victim() {
match x {
Some(ref msg) => {
(f.c)(f, true);
println(fmt!("%?", msg));
printfln!(msg);
},
None => fail!("oops"),
}

View file

@ -13,7 +13,7 @@ struct Foo(int, int);
fn main() {
let x = Foo(1, 2);
match x { //~ ERROR non-exhaustive
Foo(1, b) => println(fmt!("%d", b)),
Foo(2, b) => println(fmt!("%d", b))
Foo(1, b) => printfln!("%d", b),
Foo(2, b) => printfln!("%d", b)
}
}

View file

@ -33,5 +33,5 @@ pub fn main()
let z = @mut [1,2,3];
let z2 = z;
add(z.my_mut_slice(), z2.my_slice());
print(fmt!("%d\n", z[0]));
printfln!("%d", z[0]);
}

View file

@ -12,5 +12,5 @@ pub fn main()
let z = @mut [1,2,3];
let z2 = z;
add(z, z2);
print(fmt!("%d\n", z[0]));
printfln!("%d", z[0]);
}

View file

@ -13,5 +13,5 @@ pub fn main()
let z = @mut [1,2,3];
let z2 = z;
add(&mut z[0], &z2[0]);
print(fmt!("%d\n", z[0]));
printfln!("%d", z[0]);
}

View file

@ -13,5 +13,5 @@ pub fn main()
let z = @mut [1,2,3];
let z2 = z;
add(&mut z[0], &mut z2[0]);
print(fmt!("%d\n", z[0]));
printfln!("%d", z[0]);
}

View file

@ -18,7 +18,7 @@ trait Stuff {
impl Stuff for Foo {
fn printme(&self) {
println(fmt!("%d", self.x));
printfln!("%d", self.x);
}
}

View file

@ -10,5 +10,5 @@ pub fn main()
let z = @mut [1,2,3];
let z2 = z;
add(&z[0], &z2[0]);
print(fmt!("%d\n", z[0]));
printfln!("%d", z[0]);
}

View file

@ -19,7 +19,7 @@ pub fn main() {
//info!("%?", bt0);
do 3u.to(10u) |i| {
print(fmt!("%u\n", i));
printfln!("%u", i);
//let bt1 = sys::frame_address();
//info!("%?", bt1);

View file

@ -17,7 +17,7 @@ pub fn main() {
//let bt0 = sys::rusti::frame_address(1u32);
//info!("%?", bt0);
do cci_iter_lib::iter(~[1, 2, 3]) |i| {
print(fmt!("%d", *i));
printf!("%d", *i);
//assert!(bt0 == sys::rusti::frame_address(2u32));
}
}

View file

@ -23,7 +23,7 @@ pub fn main() {
//let bt0 = sys::frame_address();
//info!("%?", bt0);
do iter(~[1u, 2u, 3u]) |i| {
print(fmt!("%u\n", i));
printfln!("%u", i);
//let bt1 = sys::frame_address();
//info!("%?", bt1);

View file

@ -27,9 +27,9 @@ static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
static m : int = k.c.e;
pub fn main() {
io::println(fmt!("%?", p));
io::println(fmt!("%?", q));
io::println(fmt!("%?", t));
printfln!(p);
printfln!(q);
printfln!(t);
assert_eq!(p, 3);
assert_eq!(q, 3);
assert_eq!(t, 20);

View file

@ -21,5 +21,5 @@ static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0,
pub fn main() {
let (p, _) = y.x;
assert_eq!(p, - 1085102592571150096);
println(fmt!("0x%x", p as uint));
printfln!("0x%x", p as uint);
}

View file

@ -17,8 +17,8 @@ static x: &'static int = &10;
static y: &'static Pair<'static> = &Pair {a: 15, b: x};
pub fn main() {
io::println(fmt!("x = %?", *x));
io::println(fmt!("y = {a: %?, b: %?}", y.a, *(y.b)));
printfln!("x = %?", *x);
printfln!("y = {a: %?, b: %?}", y.a, *(y.b));
assert_eq!(*x, 10);
assert_eq!(*(y.b), 10);
}

View file

@ -30,6 +30,6 @@ pub fn main() {
assert_eq!(x.b, 2);
assert_eq!(x, y);
assert_eq!(z.b, 22);
io::println(fmt!("0x%x", x.b as uint));
io::println(fmt!("0x%x", z.c as uint));
printfln!("0x%x", x.b as uint);
printfln!("0x%x", z.c as uint);
}

View file

@ -14,8 +14,8 @@ static x : [int, ..4] = [1,2,3,4];
static y : &'static [int] = &[1,2,3,4];
pub fn main() {
io::println(fmt!("%?", x[1]));
io::println(fmt!("%?", y[1]));
printfln!(x[1]);
printfln!(y[1]);
assert_eq!(x[1], 2);
assert_eq!(x[3], 4);
assert_eq!(x[3], y[3]);

View file

@ -16,5 +16,5 @@ struct Foo {
pub fn main() {
let a = Foo { x: 1, y: 2 };
let c = Foo { x: 4, .. a};
println(fmt!("%?", c));
printfln!(c);
}

View file

@ -80,5 +80,5 @@ pub fn main() {
a);
let sum = foldl(filt, 0u, |accum, &&n: uint| accum + n );
io::println(fmt!("%u", sum));
printfln!("%u", sum);
}

View file

@ -42,7 +42,7 @@ pub fn main() {
let bools2 = to_bools(Storage{storage: ~[0b01100100]});
for uint::range(0, 8) |i| {
io::println(fmt!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint));
printfln!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint);
}
assert_eq!(bools, bools2);

View file

@ -4,5 +4,5 @@ pub fn main() {
x += 1;
}
assert_eq!(x, 4096);
println(fmt!("x = %u", x));
printfln!("x = %u", x);
}

View file

@ -42,11 +42,11 @@ pub fn main() {
// the following compiles and works properly
let v1: Vec2 = a * 3f;
io::println(fmt!("%f %f", v1.x, v1.y));
printfln!("%f %f", v1.x, v1.y);
// the following compiles but v2 will not be Vec2 yet and
// using it later will cause an error that the type of v2
// must be known
let v2 = a * 3f;
io::println(fmt!("%f %f", v2.x, v2.y)); // error regarding v2's type
printfln!("%f %f", v2.x, v2.y); // error regarding v2's type
}

View file

@ -35,5 +35,5 @@ impl Shape {
pub fn main(){
let s = Circle(Point { x: 1f, y: 2f }, 3f);
println(fmt!("%f", s.area(s)));
printfln!("%f", s.area(s));
}

View file

@ -19,7 +19,7 @@ struct S {
impl T for S {
fn print(&self) {
io::println(fmt!("%?", self));
printfln!(self);
}
}

View file

@ -12,7 +12,7 @@
type ErrPrinter = &fn(&str, &str);
fn example_err(prog: &str, arg: &str) {
io::println(fmt!("%s: %s", prog, arg))
printfln!("%s: %s", prog, arg)
}
fn exit(+print: ErrPrinter, prog: &str, arg: &str) {

View file

@ -114,7 +114,7 @@ fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result {
//io::println(cmd);
sb.write_str(cmd);
let res = parse_response(@sb as @io::Reader);
//io::println(fmt!("%?", res));
//printfln!(res);
res
}
@ -122,7 +122,7 @@ fn query2(cmd: ~[~str]) -> Result {
let _cmd = cmd_to_str(cmd);
do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| {
let res = parse_response(@sb as @io::Reader);
io::println(fmt!("%?", res));
printfln!(res);
res
}
}

View file

@ -4,5 +4,5 @@ pub fn main() {
count += 1;
}
assert_eq!(count, 999_999);
println(fmt!("%u", count));
printfln!("%u", count);
}

View file

@ -35,5 +35,5 @@ fn Foo(x: int, y: int) -> Foo {
pub fn main() {
let foo = Foo(3, 20);
println(fmt!("%d %d", foo.sum(), foo.product()));
printfln!("%d %d", foo.sum(), foo.product());
}

View file

@ -13,5 +13,5 @@ use std::io::println;
static FOO: int = 3;
pub fn main() {
println(fmt!("%d", FOO));
printfln!("%d", FOO);
}

View file

@ -13,5 +13,5 @@ use std::io::println;
static FOO: [int, ..3] = [1, 2, 3];
pub fn main() {
println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2]));
printfln!("%d %d %d", FOO[0], FOO[1], FOO[2]);
}

View file

@ -16,6 +16,6 @@ fn compute(i: mytype) -> int { return i.val + 20; }
pub fn main() {
let myval = mytype(Mytype{compute: compute, val: 30});
println(fmt!("%d", compute(myval)));
printfln!("%d", compute(myval));
assert_eq!((myval.compute)(myval), 50);
}

View file

@ -56,13 +56,13 @@ pub fn main() {
let primes = [2,3,5,7,11];
let mut prod = 1i;
for uint_range_rev(5, 0) |i| {
println(fmt!("uint 4 downto 0: %u", i));
printfln!("uint 4 downto 0: %u", i);
prod *= int::pow(primes[i], i);
}
assert_eq!(prod, 11*11*11*11*7*7*7*5*5*3*1);
let mut prod = 1i;
for int_range_rev(5, 0) |i| {
println(fmt!("int 4 downto 0: %d", i));
printfln!("int 4 downto 0: %d", i);
prod *= int::pow(primes[i], i as uint);
}
assert_eq!(prod, 11*11*11*11*7*7*7*5*5*3*1);

View file

@ -28,7 +28,7 @@ fn uint_range_step(a: uint, b: uint, s: int, it: &fn(uint) -> bool) -> bool {
}
pub fn main() {
println(fmt!("num-range start"));
println("num-range start");
// int and uint have same result for
// Sum{2 <= i < 100} == (Sum{1 <= i <= 99} - 1) == n*(n+1)/2 - 1 for n=99
let mut sum = 0u;
@ -105,7 +105,7 @@ pub fn main() {
let mut saw21 = false;
for uint::range_step_inclusive(0, 21, 3) |x| {
assert!(x <= 21);
println(fmt!("saw: %u", x));
printfln!("saw: %u", x);
if x == 21 { saw21 = true; }
}
assert!(saw21);

View file

@ -17,6 +17,6 @@ pub fn main() {
let mut arena = arena::Arena();
let p = &mut arena;
let x = p.alloc(|| 4u);
print(fmt!("%u", *x));
printf!("%u", *x);
assert_eq!(*x, 4u);
}

View file

@ -30,5 +30,5 @@ fn test<T:Dot> (n:int, i:int, first:T, second:T) ->int {
}
pub fn main() {
let n = test(1, 0, Nil, Nil);
io::println(fmt!("%d", n));
printfln!("%d", n);
}

View file

@ -667,7 +667,7 @@ pub fn main() {
let r = u.vals.clone();
for r.iter().advance |s| {
println(fmt!("val: %s", *s));
printfln!("val: %s", *s);
}
error!("%?", u.vals.clone());
assert_eq!(u.vals.clone(),

View file

@ -171,7 +171,7 @@ pub fn main() {
visit_ty::<~[int]>(vv);
for v.types.iter().advance |s| {
println(fmt!("type: %s", (*s).clone()));
printfln!("type: %s", (*s).clone());
}
assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]);
}

View file

@ -16,6 +16,6 @@ struct Foo {
pub fn main() {
let a = Foo { x: 1, y: 2 };
match a {
Foo { x: x, y: y } => println(fmt!("yes, %d, %d", x, y))
Foo { x: x, y: y } => printfln!("yes, %d, %d", x, y)
}
}

View file

@ -99,7 +99,7 @@ impl FloatExt for f64 {}
impl FloatExt for float {}
fn test_float_ext<T:FloatExt>(n: T) { println(fmt!("%?", n < n)) }
fn test_float_ext<T:FloatExt>(n: T) { printfln!(n < n) }
pub fn main() {
test_float_ext(1f32);

View file

@ -16,7 +16,7 @@ pub trait NumExt: Eq + Ord + Num + NumCast {}
impl NumExt for f32 {}
fn num_eq_one<T:NumExt>(n: T) {
println(fmt!("%?", n == NumCast::from(1)))
printfln!(n == NumCast::from(1))
}
pub fn main() {

View file

@ -12,5 +12,5 @@ struct Foo(int, int);
pub fn main() {
let x = Foo(1, 2);
println(fmt!("%?", x));
printfln!(x);
}

View file

@ -13,7 +13,7 @@ struct Foo(int, int);
pub fn main() {
let x = Foo(1, 2);
let Foo(y, z) = x;
println(fmt!("%d %d", y, z));
printfln!("%d %d", y, z);
assert_eq!(y, 1);
assert_eq!(z, 2);
}

View file

@ -16,7 +16,7 @@ pub fn main() {
Foo(a, b) => {
assert_eq!(a, 1);
assert_eq!(b, 2);
println(fmt!("%d %d", a, b));
printfln!("%d %d", a, b);
}
}
}

View file

@ -10,5 +10,5 @@
pub fn main() {
let x: [int, ..4] = [1, 2, 3, 4];
println(fmt!("%d", x[0]));
printfln!("%d", x[0]);
}

View file

@ -5,6 +5,6 @@ pub fn main() {
[1, ..ref tail] => &tail[0],
_ => ::std::util::unreachable()
};
println(fmt!("%d", *el));
printfln!("%d", *el);
}
}