Skip to content

Commit 3b86177

Browse files
committed
---
yaml --- r: 2068 b: refs/heads/master c: bba245f h: refs/heads/master v: v3
1 parent af2863c commit 3b86177

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 37f87161cc408ad76d4b748be428b1b206a0ed28
2+
refs/heads/master: bba245f3e6cdf9203cfafe7e8a81739a499b20eb

trunk/src/comp/front/extfmt.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr {
179179
}
180180
}
181181
}
182+
case (ty_bool) {
183+
let vec[str] path = vec("std", "ExtFmt", "RT", "bool_to_str");
184+
let vec[@ast.expr] args = vec(arg);
185+
ret make_call(arg.span, path, args);
186+
}
187+
case (ty_char) {
188+
let vec[str] path = vec("std", "ExtFmt", "RT", "char_to_str");
189+
let vec[@ast.expr] args = vec(arg);
190+
ret make_call(arg.span, path, args);
191+
}
182192
case (_) {
183193
log unsupported;
184194
fail;

trunk/src/lib/ExtFmt.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ mod RT {
271271
fn uint_to_str(uint u) -> str {
272272
ret _uint.to_str(u, 10u);
273273
}
274+
275+
fn bool_to_str(bool b) -> str {
276+
if (b) {
277+
ret "true";
278+
} else {
279+
ret "false";
280+
}
281+
}
282+
283+
fn char_to_str(char c) -> str {
284+
ret _str.from_char(c);
285+
}
274286
}
275287

276288
// Local Variables:

trunk/src/test/run-pass/syntax-extension-fmt.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// xfail-boot
12
// xfail-stage0
23
use std;
34
import std._str;
@@ -11,7 +12,13 @@ fn test(str actual, str expected) {
1112
fn main() {
1213
test(#fmt("hello %d friends and %s things", 10, "formatted"),
1314
"hello 10 friends and formatted things");
14-
test(#fmt("d: %d", 1), "d: 1");
15-
test(#fmt("i: %i", 2), "i: 2");
16-
test(#fmt("s: %s", "test"), "s: test");
15+
16+
// Simple tests for types
17+
test(#fmt("%d", 1), "1");
18+
test(#fmt("%i", 2), "2");
19+
test(#fmt("%i", -1), "-1");
20+
test(#fmt("%s", "test"), "test");
21+
test(#fmt("%b", true), "true");
22+
test(#fmt("%b", false), "false");
23+
test(#fmt("%c", 'A'), "A");
1724
}

0 commit comments

Comments
 (0)