#[deny(warnings)];
use std::fmt;
+use std::rt::io::Decorator;
+use std::rt::io::mem::MemWriter;
+use std::rt::io;
+use std::rt::io::Writer;
+use std::str;
struct A;
struct B;
let a: int = ::std::cast::transmute(3u);
format!("{}", a);
}
+
+ test_format_args();
}
// Basic test to make sure that we can invoke the `write!` macro with an
// io::Writer instance.
fn test_write() {
- use std::rt::io::Decorator;
- use std::rt::io::mem::MemWriter;
- use std::rt::io;
- use std::str;
-
let mut buf = MemWriter::new();
write!(&mut buf as &mut io::Writer, "{}", 3);
{
println!("this is a {}", "test");
println!("{foo}", foo="bar");
}
+
+// Just make sure that the macros are defined, there's not really a lot that we
+// can do with them just yet (to test the output)
+fn test_format_args() {
+ let mut buf = MemWriter::new();
+ {
+ let w = &mut buf as &mut io::Writer;
+ format_args!(|args| { fmt::write(w, args) }, "{}", 1);
+ format_args!(|args| { fmt::write(w, args) }, "test");
+ format_args!(|args| { fmt::write(w, args) }, "{test}", test=3);
+ }
+ let s = str::from_utf8_owned(buf.inner());
+ t!(s, "1test3");
+
+ let s = format_args!(fmt::format, "hello {}", "world");
+ t!(s, "hello world");
+}