]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/shift-various-types.rs
Merge pull request #20793 from ktossell/rustdoc-fixedvector-syntax
[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 struct Panolpy {
14     i8: i8,
15     i16: i16,
16     i32: i32,
17     i64: i64,
18     isize: isize,
19
20     u8: u8,
21     u16: u16,
22     u32: u32,
23     u64: u64,
24     usize: usize,
25 }
26
27 fn foo(p: &Panolpy) {
28     assert_eq!(22_i32 >> p.i8, 11_i32);
29     assert_eq!(22_i32 >> p.i16, 11_i32);
30     assert_eq!(22_i32 >> p.i32, 11_i32);
31     assert_eq!(22_i32 >> p.i64, 11_i32);
32     assert_eq!(22_i32 >> p.isize, 11_i32);
33
34     assert_eq!(22_i32 >> p.u8, 11_i32);
35     assert_eq!(22_i32 >> p.u16, 11_i32);
36     assert_eq!(22_i32 >> p.u32, 11_i32);
37     assert_eq!(22_i32 >> p.u64, 11_i32);
38     assert_eq!(22_i32 >> p.usize, 11_i32);
39 }
40
41 fn main() {
42     let p = Panolpy {
43         i8: 1,
44         i16: 1,
45         i32: 1,
46         i64: 1,
47         isize: 1,
48
49         u8: 1,
50         u16: 1,
51         u32: 1,
52         u64: 1,
53         usize: 1,
54     };
55     foo(&p)
56 }