blob: d987203344723b351dcf51d4de5811ad72ee3e88 [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 Walton91436882013-02-14 19:47:0015impl cmp::Eq for foo {
Patrick Walton3eda11a2013-03-22 18:23:2116 fn eq(&self, other: &foo) -> bool {
Patrick Walton318e5342012-11-15 02:59:3017 ((*self) as uint) == ((*other) as uint)
Patrick Walton96534362012-08-27 23:26:3518 }
Patrick Walton3eda11a2013-03-22 18:23:2119 fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
Patrick Walton96534362012-08-27 23:26:3520}
21
Graydon Hoare89c8ef72013-02-02 03:43:1722pub fn main() {
Patrick Walton96534362012-08-27 23:26:3523 let a = (1, 2, 3);
24 let b = (1, 2, 3);
Patrick Waltond7e74b52013-03-06 21:58:0225 fail_unless!((a == b));
26 fail_unless!((a != (1, 2, 4)));
27 fail_unless!((a < (1, 2, 4)));
28 fail_unless!((a <= (1, 2, 4)));
29 fail_unless!(((1, 2, 4) > a));
30 fail_unless!(((1, 2, 4) >= a));
Marijn Haverbekedf7f21d2011-07-27 12:19:3931 let x = large;
32 let y = small;
Patrick Waltond7e74b52013-03-06 21:58:0233 fail_unless!((x != y));
34 fail_unless!((x == large));
35 fail_unless!((x != small));
Brian Anderson518dc522011-08-19 22:16:4836}