about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-08-14 20:40:15 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-08-16 16:09:33 -0700
commit22c7bbfd0c49330015e24adeb0f2c45ae669c29f (patch)
tree44c61eb2f97f4a828c691db400dffdf17765c911 /src/test
parent109274426a7cd676b9aa1bb06afd9f86b44f6e9b (diff)
downloadrust-22c7bbfd0c49330015e24adeb0f2c45ae669c29f.tar.gz
rust-22c7bbfd0c49330015e24adeb0f2c45ae669c29f.zip
Delegate `{}` to Default instead of Poly
By using a separate trait this is overridable on a per-type basis and makes room
for the possibility of even more arguments passed in for the future.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/ifmt.rs30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs
index 8076c081e87..cba28463f99 100644
--- a/src/test/run-pass/ifmt.rs
+++ b/src/test/run-pass/ifmt.rs
@@ -25,16 +25,36 @@ pub fn main() {
     macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a, $b.to_owned()) })
 
     // Make sure there's a poly formatter that takes anything
-    t!(ifmt!("{}", 1), "1");
-    t!(ifmt!("{}", A), "{}");
-    t!(ifmt!("{}", ()), "()");
-    t!(ifmt!("{}", @(~1, "foo")), "@(~1, \"foo\")");
+    t!(ifmt!("{:?}", 1), "1");
+    t!(ifmt!("{:?}", A), "{}");
+    t!(ifmt!("{:?}", ()), "()");
+    t!(ifmt!("{:?}", @(~1, "foo")), "@(~1, \"foo\")");
 
     // Various edge cases without formats
     t!(ifmt!(""), "");
     t!(ifmt!("hello"), "hello");
     t!(ifmt!("hello \\{"), "hello {");
 
+    // default formatters should work
+    t!(ifmt!("{}", 1i), "1");
+    t!(ifmt!("{}", 1i8), "1");
+    t!(ifmt!("{}", 1i16), "1");
+    t!(ifmt!("{}", 1i32), "1");
+    t!(ifmt!("{}", 1i64), "1");
+    t!(ifmt!("{}", 1u), "1");
+    t!(ifmt!("{}", 1u8), "1");
+    t!(ifmt!("{}", 1u16), "1");
+    t!(ifmt!("{}", 1u32), "1");
+    t!(ifmt!("{}", 1u64), "1");
+    t!(ifmt!("{}", 1.0f), "1");
+    t!(ifmt!("{}", 1.0f32), "1");
+    t!(ifmt!("{}", 1.0f64), "1");
+    t!(ifmt!("{}", "a"), "a");
+    t!(ifmt!("{}", ~"a"), "a");
+    t!(ifmt!("{}", @"a"), "a");
+    t!(ifmt!("{}", false), "false");
+    t!(ifmt!("{}", 'a'), "a");
+
     // At least exercise all the formats
     t!(ifmt!("{:b}", true), "true");
     t!(ifmt!("{:c}", '☃'), "☃");
@@ -56,7 +76,7 @@ pub fn main() {
     t!(ifmt!("{foo} {bar}", foo=0, bar=1), "0 1");
     t!(ifmt!("{foo} {1} {bar} {0}", 0, 1, foo=2, bar=3), "2 1 3 0");
     t!(ifmt!("{} {0:s}", "a"), "a a");
-    t!(ifmt!("{} {0}", "a"), "\"a\" \"a\"");
+    t!(ifmt!("{} {0}", "a"), "a a");
 
     // Methods should probably work
     t!(ifmt!("{0, plural, =1{a#} =2{b#} zero{c#} other{d#}}", 0u), "c0");