3 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
4 // file at the top-level directory of this distribution and at
5 // http://rust-lang.org/COPYRIGHT.
7 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 // option. This file may not be copied, modified, or distributed
11 // except according to those terms.
13 #[forbid(deprecated_pattern)];
17 // These tests used to be separate files, but I wanted to refactor all
20 use EBReader = std::ebml::reader;
21 use EBWriter = std::ebml::writer;
25 use std::serialize::{Decodable, Encodable};
30 Encodable<EBWriter::Encoder> +
31 Decodable<EBReader::Decoder>
33 let bytes = do io::with_bytes_writer |wr| {
34 let ebml_w = &EBWriter::Encoder(wr);
37 let d = EBReader::Doc(@bytes);
38 let a2: A = Decodable::decode(&EBReader::Decoder(d));
42 #[deriving(Decodable, Encodable)]
49 impl cmp::Eq for Expr {
50 fn eq(&self, other: &Expr) -> bool {
54 Val(e0b) => e0a == e0b,
60 Plus(e0b, e1b) => e0a == e0b && e1a == e1b,
66 Minus(e0b, e1b) => e0a == e0b && e1a == e1b,
72 fn ne(&self, other: &Expr) -> bool { !(*self).eq(other) }
75 impl cmp::Eq for Point {
76 fn eq(&self, other: &Point) -> bool {
77 self.x == other.x && self.y == other.y
79 fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
82 impl<T:cmp::Eq> cmp::Eq for Quark<T> {
83 fn eq(&self, other: &Quark<T>) -> bool {
94 Bottom(ref r) => q == r
99 fn ne(&self, other: &Quark<T>) -> bool { !(*self).eq(other) }
102 impl cmp::Eq for CLike {
103 fn eq(&self, other: &CLike) -> bool {
104 (*self) as int == *other as int
106 fn ne(&self, other: &CLike) -> bool { !self.eq(other) }
109 #[deriving(Decodable, Encodable, Eq)]
116 #[deriving(Decodable, Encodable)]
117 struct SomeStruct { v: ~[uint] }
119 #[deriving(Decodable, Encodable)]
120 struct Point {x: uint, y: uint}
122 #[deriving(Decodable, Encodable)]
128 #[deriving(Decodable, Encodable)]
129 enum CLike { A, B, C }
132 let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
135 let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
138 let a = &Point {x: 3u, y: 5u};
141 let a = &@[1u, 2u, 3u];
147 let a = &Bottom(222u);
156 let a = &time::now();