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.
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 use std::cmp::Ordering;
13 // Test default methods in PartialOrd and PartialEq
17 impl PartialEq for Fool {
18 fn eq(&self, other: &Fool) -> bool {
19 let Fool(this) = *self;
20 let Fool(other) = *other;
27 impl PartialEq for Int {
28 fn eq(&self, other: &Int) -> bool {
29 let Int(this) = *self;
30 let Int(other) = *other;
35 impl PartialOrd for Int {
36 fn partial_cmp(&self, other: &Int) -> Option<Ordering> {
37 let Int(this) = *self;
38 let Int(other) = *other;
39 this.partial_cmp(&other)
45 impl PartialEq for RevInt {
46 fn eq(&self, other: &RevInt) -> bool {
47 let RevInt(this) = *self;
48 let RevInt(other) = *other;
53 impl PartialOrd for RevInt {
54 fn partial_cmp(&self, other: &RevInt) -> Option<Ordering> {
55 let RevInt(this) = *self;
56 let RevInt(other) = *other;
57 other.partial_cmp(&this)
62 assert!(Int(2) > Int(1));
63 assert!(Int(2) >= Int(1));
64 assert!(Int(1) >= Int(1));
65 assert!(Int(1) < Int(2));
66 assert!(Int(1) <= Int(2));
67 assert!(Int(1) <= Int(1));
69 assert!(RevInt(2) < RevInt(1));
70 assert!(RevInt(2) <= RevInt(1));
71 assert!(RevInt(1) <= RevInt(1));
72 assert!(RevInt(1) > RevInt(2));
73 assert!(RevInt(1) >= RevInt(2));
74 assert!(RevInt(1) >= RevInt(1));
76 assert!(Fool(true) == Fool(false));
77 assert!(Fool(true) != Fool(true));
78 assert!(Fool(false) != Fool(false));
79 assert!(Fool(false) == Fool(true));