]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-8860.rs
auto merge of #15210 : luqmana/rust/windoc, r=alexcrichton
[rust.git] / src / test / run-pass / issue-8860.rs
1 // Copyright 2012-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
12 extern crate green;
13
14 static mut DROP: int = 0i;
15 static mut DROP_S: int = 0i;
16 static mut DROP_T: int = 0i;
17
18 #[start]
19 fn start(argc: int, argv: *const *const u8) -> int {
20     let ret = green::start(argc, argv, green::basic::event_loop, main);
21     unsafe {
22         assert_eq!(2, DROP);
23         assert_eq!(1, DROP_S);
24         assert_eq!(1, DROP_T);
25     }
26     ret
27 }
28
29 struct S;
30 impl Drop for S {
31     fn drop(&mut self) {
32         unsafe {
33             DROP_S += 1;
34             DROP += 1;
35         }
36     }
37 }
38 fn f(ref _s: S) {}
39
40 struct T { i: int }
41 impl Drop for T {
42     fn drop(&mut self) {
43         unsafe {
44             DROP_T += 1;
45             DROP += 1;
46         }
47     }
48 }
49 fn g(ref _t: T) {}
50
51 fn main() {
52     let s = S;
53     f(s);
54     unsafe {
55         assert_eq!(1, DROP);
56         assert_eq!(1, DROP_S);
57     }
58     let t = T { i: 1 };
59     g(t);
60     unsafe { assert_eq!(1, DROP_T); }
61 }