Skip to content

Commit c1f82f5

Browse files
committed
---
yaml --- r: 42639 b: refs/heads/try c: cb504f5 h: refs/heads/master i: 42637: 56c2197 42635: 814d994 42631: 637b412 42623: ef6d584 v: v3
1 parent 0ba1db5 commit c1f82f5

File tree

2 files changed

+51
-28
lines changed

2 files changed

+51
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: ad25e208ee4978ca20123bcd2f34c16504518b8d
5+
refs/heads/try: cb504f54045fc21ee245ebfd32dd5b1312ddee4d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/libsyntax/print/pprust.rs

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,6 @@ fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
170170
}
171171
}
172172

173-
#[test]
174-
fn test_fun_to_str() {
175-
let decl: ast::fn_decl = ast::fn_decl {
176-
inputs: ~[],
177-
output: @ast::Ty {id: 0,
178-
node: ast::ty_nil,
179-
span: ast_util::dummy_sp()},
180-
//purity: ast::impure_fn,
181-
cf: ast::return_val
182-
};
183-
assert fun_to_str(decl, "abba", ~[]) == "fn abba()";
184-
}
185-
186173
fn block_to_str(blk: ast::blk, intr: @ident_interner) -> ~str {
187174
do io::with_str_writer |wr| {
188175
let s = rust_printer(wr, intr);
@@ -207,20 +194,6 @@ fn variant_to_str(var: ast::variant, intr: @ident_interner) -> ~str {
207194
to_str(var, print_variant, intr)
208195
}
209196

210-
#[test]
211-
fn test_variant_to_str() {
212-
let var = ast_util::respan(ast_util::dummy_sp(), {
213-
name: "principle_skinner",
214-
attrs: ~[],
215-
args: ~[],
216-
id: 0,
217-
disr_expr: None
218-
});
219-
220-
let varstr = variant_to_str(var);
221-
assert varstr == "principle_skinner";
222-
}
223-
224197
fn cbox(s: ps, u: uint) {
225198
s.boxes.push(pp::consistent);
226199
pp::cbox(s.s, u);
@@ -2273,6 +2246,56 @@ fn proto_to_str(p: ast::Proto) -> ~str {
22732246
};
22742247
}
22752248

2249+
#[cfg(test)]
2250+
mod test {
2251+
use ast;
2252+
use ast_util;
2253+
use parse;
2254+
use super::*;
2255+
//use util;
2256+
2257+
fn string_check<T : Eq> (given : &T, expected: &T) {
2258+
if !(given == expected) {
2259+
fail (fmt!("given %?, expected %?",given,expected));
2260+
}
2261+
}
2262+
2263+
#[test]
2264+
fn test_fun_to_str() {
2265+
let mock_interner = parse::token::mk_fake_ident_interner();
2266+
let abba_ident = mock_interner.intern(@~"abba");
2267+
2268+
let decl: ast::fn_decl = ast::fn_decl {
2269+
inputs: ~[],
2270+
output: @ast::Ty {id: 0,
2271+
node: ast::ty_nil,
2272+
span: ast_util::dummy_sp()},
2273+
cf: ast::return_val
2274+
};
2275+
assert fun_to_str(decl, abba_ident, ~[],mock_interner)
2276+
== ~"fn abba()";
2277+
}
2278+
2279+
#[test]
2280+
fn test_variant_to_str() {
2281+
let mock_interner = parse::token::mk_fake_ident_interner();
2282+
let ident = mock_interner.intern(@~"principal_skinner");
2283+
2284+
let var = ast_util::respan(ast_util::dummy_sp(), ast::variant_ {
2285+
name: ident,
2286+
attrs: ~[],
2287+
// making this up as I go.... ?
2288+
kind: ast::tuple_variant_kind(~[]),
2289+
id: 0,
2290+
disr_expr: None,
2291+
vis: ast::public,
2292+
});
2293+
2294+
let varstr = variant_to_str(var,mock_interner);
2295+
string_check(&varstr,&~"pub principal_skinner");
2296+
}
2297+
}
2298+
22762299
//
22772300
// Local Variables:
22782301
// mode: rust

0 commit comments

Comments
 (0)