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 extern crate serialize;
17 // These tests used to be separate files, but I wanted to refactor all
20 use std::collections::{HashMap, HashSet};
22 use rbml::reader as EBReader;
23 use rbml::writer as EBWriter;
27 use serialize::{Decodable, Encodable};
29 fn test_rbml<'a, 'b, A:
31 Encodable<EBWriter::Encoder<'a>> +
32 Decodable<EBReader::Decoder<'b>>
34 let mut wr = Vec::new();
35 let mut rbml_w = EBwriter::Encoder::new(&mut wr);
36 a1.encode(&mut rbml_w);
38 let d: serialize::rbml::Doc<'a> = EBDoc::new(wr[]);
39 let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
40 let a2: A = Decodable::decode(&mut decoder);
44 #[deriving(Decodable, Encodable)]
51 impl cmp::Eq for Expr {
52 fn eq(&self, other: &Expr) -> bool {
56 Val(e0b) => e0a == e0b,
62 Plus(e0b, e1b) => e0a == e0b && e1a == e1b,
68 Minus(e0b, e1b) => e0a == e0b && e1a == e1b,
74 fn ne(&self, other: &Expr) -> bool { !(*self).eq(other) }
77 impl cmp::Eq for Point {
78 fn eq(&self, other: &Point) -> bool {
79 self.x == other.x && self.y == other.y
81 fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
84 impl<T:cmp::Eq> cmp::Eq for Quark<T> {
85 fn eq(&self, other: &Quark<T>) -> bool {
96 Bottom(ref r) => q == r
101 fn ne(&self, other: &Quark<T>) -> bool { !(*self).eq(other) }
104 impl cmp::Eq for CLike {
105 fn eq(&self, other: &CLike) -> bool {
106 (*self) as int == *other as int
108 fn ne(&self, other: &CLike) -> bool { !self.eq(other) }
111 #[deriving(Decodable, Encodable, Eq)]
118 #[deriving(Decodable, Encodable)]
119 struct SomeStruct { v: Vec<uint> }
121 #[deriving(Decodable, Encodable)]
122 struct Point {x: uint, y: uint}
124 #[deriving(Decodable, Encodable)]
130 #[deriving(Decodable, Encodable)]
131 enum CLike { A, B, C }
134 let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
137 let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
140 let a = &Point {x: 3u, y: 5u};
146 let a = &Bottom(222u);
155 let a = &time::now();
162 let mut a = HashMap::new();
167 let mut a = HashSet::new();