blob: 18398ad6710399fd813a1d748343b15e509713cf [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481// Copyright 2012 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.
4//
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.
10
Graydon Hoarece729932011-06-15 18:19:5011
12
Patrick Walton59ebe6a2012-01-20 02:31:0813enum foo { large, small, }
Graydon Hoare9f0a6c22010-09-21 18:47:1014
Patrick Walton96534362012-08-27 23:26:3515impl foo : cmp::Eq {
Patrick Walton318e5342012-11-15 02:59:3016 pure fn eq(&self, other: &foo) -> bool {
17 ((*self) as uint) == ((*other) as uint)
Patrick Walton96534362012-08-27 23:26:3518 }
Patrick Walton318e5342012-11-15 02:59:3019 pure fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
Patrick Walton96534362012-08-27 23:26:3520}
21
Graydon Hoare9f0a6c22010-09-21 18:47:1022fn main() {
Patrick Walton96534362012-08-27 23:26:3523 let a = (1, 2, 3);
24 let b = (1, 2, 3);
Graydon Hoarece729932011-06-15 18:19:5025 assert (a == b);
Patrick Walton96534362012-08-27 23:26:3526 assert (a != (1, 2, 4));
27 assert (a < (1, 2, 4));
28 assert (a <= (1, 2, 4));
29 assert ((1, 2, 4) > a);
30 assert ((1, 2, 4) >= a);
Marijn Haverbekedf7f21d2011-07-27 12:19:3931 let x = large;
32 let y = small;
Graydon Hoarece729932011-06-15 18:19:5033 assert (x != y);
34 assert (x == large);
35 assert (x != small);
Brian Anderson518dc522011-08-19 22:16:4836}