From 1bec738c56c221843adbb022914c1de6e3bd7c61 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 17 Apr 2011 17:24:17 -0400 Subject: Support #fmt precision for bools, with same rules as strings Not totally confident this is desirable. The alternative would be to make it a compile error. --- src/test/run-pass/syntax-extension-fmt.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/test') diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index 935c87c1..5c66b17a 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -104,4 +104,12 @@ fn main() { test(#fmt("%.5x", 127u), "0007f"); test(#fmt("%.5t", 3u), "00011"); test(#fmt("%.5c", 'A'), "A"); + + // Bool precision. I'm not sure if it's good or bad to have bool + // conversions support precision - it's not standard printf so we + // can do whatever. For now I'm making it behave the same as string + // conversions. + test(#fmt("%.b", true), ""); + test(#fmt("%.0b", true), ""); + test(#fmt("%.1b", true), "t"); } -- cgit v1.2.3