1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-test FIXME(#5121)
14 #[feature(managed_boxes)];
17 extern crate serialize;
19 // These tests used to be separate files, but I wanted to refactor all
22 use std::hashmap::{HashMap, HashSet};
24 use EBReader = serialize::ebml::reader;
25 use EBWriter = serialize::ebml::writer;
29 use serialize::{Decodable, Encodable};
31 fn test_ebml<'a, 'b, A:
33 Encodable<EBWriter::Encoder<'a>> +
34 Decodable<EBReader::Decoder<'b>>
36 let mut wr = std::io::MemWriter::new();
37 let mut ebml_w = EBWriter::Encoder(&mut wr);
38 a1.encode(&mut ebml_w);
39 let bytes = wr.get_ref();
41 let d: serialize::ebml::Doc<'a> = EBReader::Doc(bytes);
42 let mut decoder: EBReader::Decoder<'a> = EBReader::Decoder(d);
43 let a2: A = Decodable::decode(&mut decoder);
47 #[deriving(Decodable, Encodable)]
54 impl cmp::Eq for Expr {
55 fn eq(&self, other: &Expr) -> bool {
59 Val(e0b) => e0a == e0b,
65 Plus(e0b, e1b) => e0a == e0b && e1a == e1b,
71 Minus(e0b, e1b) => e0a == e0b && e1a == e1b,
77 fn ne(&self, other: &Expr) -> bool { !(*self).eq(other) }
80 impl cmp::Eq for Point {
81 fn eq(&self, other: &Point) -> bool {
82 self.x == other.x && self.y == other.y
84 fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
87 impl<T:cmp::Eq> cmp::Eq for Quark<T> {
88 fn eq(&self, other: &Quark<T>) -> bool {
99 Bottom(ref r) => q == r
104 fn ne(&self, other: &Quark<T>) -> bool { !(*self).eq(other) }
107 impl cmp::Eq for CLike {
108 fn eq(&self, other: &CLike) -> bool {
109 (*self) as int == *other as int
111 fn ne(&self, other: &CLike) -> bool { !self.eq(other) }
114 #[deriving(Decodable, Encodable, Eq)]
121 #[deriving(Decodable, Encodable)]
122 struct SomeStruct { v: Vec<uint> }
124 #[deriving(Decodable, Encodable)]
125 struct Point {x: uint, y: uint}
127 #[deriving(Decodable, Encodable)]
133 #[deriving(Decodable, Encodable)]
134 enum CLike { A, B, C }
137 let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
140 let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
143 let a = &Point {x: 3u, y: 5u};
149 let a = &Bottom(222u);
158 let a = &time::now();
165 let mut a = HashMap::new();
170 let mut a = HashSet::new();