1
1
// xfail-fast
2
2
3
- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
3
+ // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
4
4
// file at the top-level directory of this distribution and at
5
5
// http://rust-lang.org/COPYRIGHT.
6
6
//
10
10
// option. This file may not be copied, modified, or distributed
11
11
// except according to those terms.
12
12
13
- // xfail-test #6122
13
+ # [ feature ( managed_boxes ) ] ;
14
14
15
15
extern mod extra;
16
16
17
17
// These tests used to be separate files, but I wanted to refactor all
18
18
// the common code.
19
19
20
20
use std:: hashmap:: { HashMap , HashSet } ;
21
+ use std:: io:: Decorator ;
21
22
22
23
use EBReader = extra:: ebml:: reader;
23
24
use EBWriter = extra:: ebml:: writer;
@@ -32,17 +33,14 @@ fn test_ebml<A:
32
33
Encodable < EBWriter :: Encoder > +
33
34
Decodable < EBReader :: Decoder >
34
35
> ( 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
+
39
41
let d = EBReader :: Doc ( @bytes) ;
40
42
let mut decoder = EBReader :: Decoder ( d) ;
41
43
let a2: A = Decodable :: decode ( & mut decoder) ;
42
- if !( * a1 == a2) {
43
- :: std:: sys:: FailWithCause :: fail_with ( ~"explicit failure" + "foo" ,
44
- "auto-encode.rs" , 43 u) ;
45
- }
46
44
assert ! ( * a1 == a2) ;
47
45
}
48
46
@@ -139,47 +137,41 @@ pub fn main() {
139
137
let a = & Plus ( @Minus ( @Val ( 3 u) , @Val ( 10 u) ) , @Plus ( @Val ( 22 u) , @Val ( 5 u) ) ) ;
140
138
test_ebml ( a) ;
141
139
142
- // let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
143
- // test_ebml(a);
140
+ let a = & Spanned { lo : 0 u, hi : 5 u, node : 22 u} ;
141
+ test_ebml ( a) ;
144
142
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 : 3 u, y : 5 u} ;
144
+ test_ebml ( a) ;
145
+
146
+ let a = & @[ 1 u, 2 u, 3 u] ;
147
+ test_ebml ( a) ;
148
+
149
+ let a = & Top ( 22 u) ;
150
+ test_ebml ( a) ;
151
+
152
+ let a = & Bottom ( 222 u) ;
153
+ test_ebml ( a) ;
154
+
155
+ let a = & A ;
156
+ test_ebml ( a) ;
157
+
158
+ let a = & B ;
159
+ test_ebml ( a) ;
162
160
163
- println ( "Hi1" ) ;
164
161
let a = & time:: now ( ) ;
165
162
test_ebml ( a) ;
166
163
167
- println ( "Hi2" ) ;
168
- // test_ebml(&1.0f32);
169
- // test_ebml(&1.0f64);
170
- test_ebml ( & 1.0 f) ;
171
- // println("Hi3");
172
- // test_ebml(&'a');
164
+ test_ebml ( & 1.0f32 ) ;
165
+ test_ebml ( & 1.0f64 ) ;
166
+ test_ebml ( & 'a' ) ;
173
167
174
- println ( "Hi4" ) ;
175
168
let mut a = HashMap :: new ( ) ;
176
169
test_ebml ( & a) ;
177
170
a. insert ( 1 , 2 ) ;
178
- println ( "Hi4" ) ;
179
171
test_ebml ( & a) ;
180
172
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) ;
185
177
}
0 commit comments