Graydon Hoare | d1affff | 2012-12-11 01:32:48 | [diff] [blame] | 1 | // 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 Hoare | ce72993 | 2011-06-15 18:19:50 | [diff] [blame] | 11 | |
| 12 | |
Patrick Walton | 59ebe6a | 2012-01-20 02:31:08 | [diff] [blame] | 13 | enum foo { large, small, } |
Graydon Hoare | 9f0a6c2 | 2010-09-21 18:47:10 | [diff] [blame] | 14 | |
Patrick Walton | 206ab89 | 2013-05-25 02:35:29 | [diff] [blame] | 15 | impl Eq for foo { |
Patrick Walton | 3eda11a | 2013-03-22 18:23:21 | [diff] [blame] | 16 | fn eq(&self, other: &foo) -> bool { |
Patrick Walton | 318e534 | 2012-11-15 02:59:30 | [diff] [blame] | 17 | ((*self) as uint) == ((*other) as uint) |
Patrick Walton | 9653436 | 2012-08-27 23:26:35 | [diff] [blame] | 18 | } |
Patrick Walton | 3eda11a | 2013-03-22 18:23:21 | [diff] [blame] | 19 | fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } |
Patrick Walton | 9653436 | 2012-08-27 23:26:35 | [diff] [blame] | 20 | } |
| 21 | |
Graydon Hoare | 89c8ef7 | 2013-02-02 03:43:17 | [diff] [blame] | 22 | pub fn main() { |
Patrick Walton | 9653436 | 2012-08-27 23:26:35 | [diff] [blame] | 23 | let a = (1, 2, 3); |
| 24 | let b = (1, 2, 3); |
Corey Richardson | cc57ca0 | 2013-05-19 02:02:45 | [diff] [blame] | 25 | assert_eq!(a, b); |
Patrick Walton | 1e91595 | 2013-03-29 01:39:09 | [diff] [blame] | 26 | 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 Haverbeke | df7f21d | 2011-07-27 12:19:39 | [diff] [blame] | 31 | let x = large; |
| 32 | let y = small; |
Patrick Walton | 1e91595 | 2013-03-29 01:39:09 | [diff] [blame] | 33 | assert!((x != y)); |
Corey Richardson | cc57ca0 | 2013-05-19 02:02:45 | [diff] [blame] | 34 | assert_eq!(x, large); |
Patrick Walton | 1e91595 | 2013-03-29 01:39:09 | [diff] [blame] | 35 | assert!((x != small)); |
Brian Anderson | 518dc52 | 2011-08-19 22:16:48 | [diff] [blame] | 36 | } |