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