]> git.proxmox.com Git - rustc.git/blame - src/test/ui/structured-compare.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / ui / structured-compare.rs
CommitLineData
416331ca
XL
1// run-pass
2
0bf4aa26 3#![allow(non_camel_case_types)]
223e47cc
LB
4
5
c34b1796 6#[derive(Copy, Clone, Debug)]
223e47cc
LB
7enum foo { large, small, }
8
1a4d82fc 9impl PartialEq for foo {
223e47cc 10 fn eq(&self, other: &foo) -> bool {
c34b1796 11 ((*self) as usize) == ((*other) as usize)
223e47cc
LB
12 }
13 fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
14}
15
16pub fn main() {
85aaf69f
SL
17 let a = (1, 2, 3);
18 let b = (1, 2, 3);
970d7e83 19 assert_eq!(a, b);
223e47cc
LB
20 assert!((a != (1, 2, 4)));
21 assert!((a < (1, 2, 4)));
22 assert!((a <= (1, 2, 4)));
85aaf69f
SL
23 assert!(((1, 2, 4) > a));
24 assert!(((1, 2, 4) >= a));
1a4d82fc
JJ
25 let x = foo::large;
26 let y = foo::small;
223e47cc 27 assert!((x != y));
1a4d82fc
JJ
28 assert_eq!(x, foo::large);
29 assert!((x != foo::small));
223e47cc 30}