]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-17718.rs
8eee4c9f216b93841624c467c5918f7fdc199289
[rust.git] / src / test / run-pass / issue-17718.rs
1 // Copyright 2014 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 // aux-build:issue-17718.rs
12
13 #![feature(core)]
14
15 extern crate "issue-17718" as other;
16
17 use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
18
19 const C1: uint = 1;
20 const C2: AtomicUsize = ATOMIC_USIZE_INIT;
21 const C3: fn() = foo;
22 const C4: uint = C1 * C1 + C1 / C1;
23 const C5: &'static uint = &C4;
24 const C6: uint = {
25     const C: uint = 3;
26     C
27 };
28
29 static S1: uint = 3;
30 static S2: AtomicUsize = ATOMIC_USIZE_INIT;
31
32 mod test {
33     static A: uint = 4;
34     static B: &'static uint = &A;
35     static C: &'static uint = &(A);
36 }
37
38 fn foo() {}
39
40 fn main() {
41     assert_eq!(C1, 1);
42     assert_eq!(C3(), ());
43     assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
44     assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
45     assert_eq!(C4, 2);
46     assert_eq!(*C5, 2);
47     assert_eq!(C6, 3);
48     assert_eq!(S1, 3);
49     assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0);
50     assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1);
51
52     match 1 {
53         C1 => {}
54         _ => unreachable!(),
55     }
56
57     let _a = C1;
58     let _a = C2;
59     let _a = C3;
60     let _a = C4;
61     let _a = C5;
62     let _a = C6;
63     let _a = S1;
64
65     assert_eq!(other::C1, 1);
66     assert_eq!(other::C3(), ());
67     assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
68     assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
69     assert_eq!(other::C4, 2);
70     assert_eq!(*other::C5, 2);
71     assert_eq!(other::S1, 3);
72     assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0);
73     assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1);
74
75     let _a = other::C1;
76     let _a = other::C2;
77     let _a = other::C3;
78     let _a = other::C4;
79     let _a = other::C5;
80
81     match 1 {
82         other::C1 => {}
83         _ => unreachable!(),
84     }
85 }