]> git.lizzy.rs Git - rust.git/blob - src/test/run-fail/morestack2.rs
Change finalize -> drop.
[rust.git] / src / test / run-fail / morestack2.rs
1 // Copyright 2012 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 // error-pattern:explicit failure
12
13 // This time we're testing that the stack limits are restored
14 // correctly after calling into the C stack and unwinding.
15 // See the hack in upcall_call_shim_on_c_stack where it messes
16 // with the stack limit.
17
18 extern mod extra;
19
20 use std::libc;
21 use std::task;
22
23 mod rustrt {
24     use std::libc;
25
26     pub extern {
27         pub fn rust_get_argc() -> libc::c_int;
28     }
29 }
30
31 fn getbig_call_c_and_fail(i: int) {
32     if i != 0 {
33         getbig_call_c_and_fail(i - 1);
34     } else {
35         unsafe {
36             rustrt::rust_get_argc();
37             fail!();
38         }
39     }
40 }
41
42 struct and_then_get_big_again {
43   x:int,
44 }
45
46 impl Drop for and_then_get_big_again {
47     fn drop(&self) {
48         fn getbig(i: int) {
49             if i != 0 {
50                 getbig(i - 1);
51             }
52         }
53         getbig(10000);
54     }
55 }
56
57 fn and_then_get_big_again(x:int) -> and_then_get_big_again {
58     and_then_get_big_again {
59         x: x
60     }
61 }
62
63 fn main() {
64     do task::spawn {
65         let r = and_then_get_big_again(4);
66         getbig_call_c_and_fail(10000);
67     };
68 }