]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/issues/issue-15523.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / issues / issue-15523.rs
CommitLineData
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)]
18enum E1 {
19 Pos2 = 2,
20 Neg1 = -1,
21 Pos1 = 1,
22}
23
24#[derive(PartialEq, PartialOrd)]
25#[repr(u8)]
26enum E2 {
27 Pos2 = 2,
28 PosMax = !0 as u8,
29 Pos1 = 1,
30}
31
32#[derive(PartialEq, PartialOrd)]
33#[repr(i8)]
34enum E3 {
35 Pos2 = 2,
36 Neg1 = -1_i8,
37 Pos1 = 1,
38}
39
40fn 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}