]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/shift-various-types.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / run-pass / shift-various-types.rs
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
11 // Test that we can do shifts by any integral type.
12
13
14 struct Panolpy {
15     i8: i8,
16     i16: i16,
17     i32: i32,
18     i64: i64,
19     isize: isize,
20
21     u8: u8,
22     u16: u16,
23     u32: u32,
24     u64: u64,
25     usize: usize,
26 }
27
28 fn foo(p: &Panolpy) {
29     assert_eq!(22 >> p.i8, 11);
30     assert_eq!(22 >> p.i16, 11);
31     assert_eq!(22 >> p.i32, 11);
32     assert_eq!(22 >> p.i64, 11);
33     assert_eq!(22 >> p.isize, 11);
34
35     assert_eq!(22 >> p.u8, 11);
36     assert_eq!(22 >> p.u16, 11);
37     assert_eq!(22 >> p.u32, 11);
38     assert_eq!(22 >> p.u64, 11);
39     assert_eq!(22 >> p.usize, 11);
40 }
41
42 fn main() {
43     let p = Panolpy {
44         i8: 1,
45         i16: 1,
46         i32: 1,
47         i64: 1,
48         isize: 1,
49
50         u8: 1,
51         u16: 1,
52         u32: 1,
53         u64: 1,
54         usize: 1,
55     };
56     foo(&p)
57 }