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 fails when compared as the
13 // second element, so this passes iff the instances shortcircuit.
17 fn eq(&self, _: &FailCmp) -> bool { fail!("eq") }
20 impl Ord for FailCmp {
21 fn lt(&self, _: &FailCmp) -> bool { fail!("lt") }
24 impl TotalEq for FailCmp {
25 fn equals(&self, _: &FailCmp) -> bool { fail!("equals") }
28 impl TotalOrd for FailCmp {
29 fn cmp(&self, _: &FailCmp) -> Ordering { fail!("cmp") }
32 #[deriving(Eq,Ord,TotalEq,TotalOrd)]
39 let a = ShortCircuit { x: 1, y: FailCmp };
40 let b = ShortCircuit { x: 2, y: FailCmp };
44 assert!(!a.equals(&b));
45 assert_eq!(a.cmp(&b), ::std::cmp::Less);