1 // Copyright 2013 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 // check that the derived impls for the comparison traits shortcircuit
12 // where possible, by having a type that panics when compared as the
13 // second element, so this passes iff the instances shortcircuit.
15 use std::cmp::Ordering;
18 impl PartialEq for FailCmp {
19 fn eq(&self, _: &FailCmp) -> bool { panic!("eq") }
22 impl PartialOrd for FailCmp {
23 fn partial_cmp(&self, _: &FailCmp) -> Option<Ordering> { panic!("partial_cmp") }
26 impl Eq for FailCmp {}
28 impl Ord for FailCmp {
29 fn cmp(&self, _: &FailCmp) -> Ordering { panic!("cmp") }
32 #[deriving(PartialEq,PartialOrd,Eq,Ord)]
39 let a = ShortCircuit { x: 1, y: FailCmp };
40 let b = ShortCircuit { x: 2, y: FailCmp };
44 assert_eq!(a.cmp(&b), ::std::cmp::Ordering::Less);