]>
Commit | Line | Data |
---|---|---|
9346a6ac AL |
1 | // Copyright 2015 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 | ||
b7449926 | 11 | // run-pass |
9346a6ac AL |
12 | // Issue 15523: derive(PartialOrd) should use the provided |
13 | // discriminant values for the derived ordering. | |
14 | // | |
15 | // This is checking the basic functionality. | |
16 | ||
17 | #[derive(PartialEq, PartialOrd)] | |
18 | enum E1 { | |
19 | Pos2 = 2, | |
20 | Neg1 = -1, | |
21 | Pos1 = 1, | |
22 | } | |
23 | ||
24 | #[derive(PartialEq, PartialOrd)] | |
25 | #[repr(u8)] | |
26 | enum E2 { | |
27 | Pos2 = 2, | |
28 | PosMax = !0 as u8, | |
29 | Pos1 = 1, | |
30 | } | |
31 | ||
32 | #[derive(PartialEq, PartialOrd)] | |
33 | #[repr(i8)] | |
34 | enum E3 { | |
35 | Pos2 = 2, | |
36 | Neg1 = -1_i8, | |
37 | Pos1 = 1, | |
38 | } | |
39 | ||
40 | fn main() { | |
41 | assert!(E1::Pos2 > E1::Pos1); | |
42 | assert!(E1::Pos1 > E1::Neg1); | |
43 | assert!(E1::Pos2 > E1::Neg1); | |
44 | ||
45 | assert!(E2::Pos2 > E2::Pos1); | |
46 | assert!(E2::Pos1 < E2::PosMax); | |
47 | assert!(E2::Pos2 < E2::PosMax); | |
48 | ||
49 | assert!(E3::Pos2 > E3::Pos1); | |
50 | assert!(E3::Pos1 > E3::Neg1); | |
51 | assert!(E3::Pos2 > E3::Neg1); | |
52 | } |