Skip to content

Commit 35e5056

Browse files
committed
auto merge of #11000 : cmr/rust/auto_encode, r=alexcrichton
Closes #6122
2 parents 4e77c11 + b1fcba6 commit 35e5056

File tree

1 file changed

+34
-42
lines changed

1 file changed

+34
-42
lines changed

src/test/run-pass/auto-encode.rs

+34-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// xfail-fast
22

3-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
3+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
44
// file at the top-level directory of this distribution and at
55
// http://rust-lang.org/COPYRIGHT.
66
//
@@ -10,14 +10,15 @@
1010
// option. This file may not be copied, modified, or distributed
1111
// except according to those terms.
1212

13-
// xfail-test #6122
13+
#[feature(managed_boxes)];
1414

1515
extern mod extra;
1616

1717
// These tests used to be separate files, but I wanted to refactor all
1818
// the common code.
1919

2020
use std::hashmap::{HashMap, HashSet};
21+
use std::io::Decorator;
2122

2223
use EBReader = extra::ebml::reader;
2324
use EBWriter = extra::ebml::writer;
@@ -32,17 +33,14 @@ fn test_ebml<A:
3233
Encodable<EBWriter::Encoder> +
3334
Decodable<EBReader::Decoder>
3435
>(a1: &A) {
35-
let bytes = do io::with_bytes_writer |wr| {
36-
let mut ebml_w = EBWriter::Encoder(wr);
37-
a1.encode(&mut ebml_w)
38-
};
36+
let mut wr = @mut std::io::mem::MemWriter::new();
37+
let mut ebml_w = EBWriter::Encoder(wr);
38+
a1.encode(&mut ebml_w);
39+
let bytes = wr.inner_ref().to_owned();
40+
3941
let d = EBReader::Doc(@bytes);
4042
let mut decoder = EBReader::Decoder(d);
4143
let a2: A = Decodable::decode(&mut decoder);
42-
if !(*a1 == a2) {
43-
::std::sys::FailWithCause::fail_with(~"explicit failure" + "foo",
44-
"auto-encode.rs", 43u);
45-
}
4644
assert!(*a1 == a2);
4745
}
4846

@@ -139,47 +137,41 @@ pub fn main() {
139137
let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
140138
test_ebml(a);
141139

142-
// let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
143-
// test_ebml(a);
140+
let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
141+
test_ebml(a);
144142

145-
// let a = &Point {x: 3u, y: 5u};
146-
// test_ebml(a);
147-
//
148-
// let a = &@[1u, 2u, 3u];
149-
// test_ebml(a);
150-
//
151-
// let a = &Top(22u);
152-
// test_ebml(a);
153-
//
154-
// let a = &Bottom(222u);
155-
// test_ebml(a);
156-
//
157-
// let a = &A;
158-
// test_ebml(a);
159-
//
160-
// let a = &B;
161-
// test_ebml(a);
143+
let a = &Point {x: 3u, y: 5u};
144+
test_ebml(a);
145+
146+
let a = &@[1u, 2u, 3u];
147+
test_ebml(a);
148+
149+
let a = &Top(22u);
150+
test_ebml(a);
151+
152+
let a = &Bottom(222u);
153+
test_ebml(a);
154+
155+
let a = &A;
156+
test_ebml(a);
157+
158+
let a = &B;
159+
test_ebml(a);
162160

163-
println("Hi1");
164161
let a = &time::now();
165162
test_ebml(a);
166163

167-
println("Hi2");
168-
// test_ebml(&1.0f32);
169-
// test_ebml(&1.0f64);
170-
test_ebml(&1.0f);
171-
// println("Hi3");
172-
// test_ebml(&'a');
164+
test_ebml(&1.0f32);
165+
test_ebml(&1.0f64);
166+
test_ebml(&'a');
173167

174-
println("Hi4");
175168
let mut a = HashMap::new();
176169
test_ebml(&a);
177170
a.insert(1, 2);
178-
println("Hi4");
179171
test_ebml(&a);
180172

181-
// let mut a = HashSet::new();
182-
// test_ebml(&a);
183-
// a.insert(1);
184-
// test_ebml(&a);
173+
let mut a = HashSet::new();
174+
test_ebml(&a);
175+
a.insert(1);
176+
test_ebml(&a);
185177
}

0 commit comments

Comments
 (0)