]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/var-captured-in-stack-closure.rs
auto merge of #19628 : jbranchaud/rust/add-string-as-string-doctest, r=steveklabnik
[rust.git] / src / test / debuginfo / var-captured-in-stack-closure.rs
1 // Copyright 2013-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 // ignore-android: FIXME(#10381)
12 // min-lldb-version: 310
13
14 // compile-flags:-g
15
16 // === GDB TESTS ===================================================================================
17
18 // gdb-command:run
19
20 // gdb-command:print variable
21 // gdb-check:$1 = 1
22 // gdb-command:print constant
23 // gdb-check:$2 = 2
24 // gdb-command:print a_struct
25 // gdb-check:$3 = {a = -3, b = 4.5, c = 5}
26 // gdb-command:print *struct_ref
27 // gdb-check:$4 = {a = -3, b = 4.5, c = 5}
28 // gdb-command:print *owned
29 // gdb-check:$5 = 6
30
31 // gdb-command:continue
32
33 // gdb-command:print variable
34 // gdb-check:$6 = 2
35 // gdb-command:print constant
36 // gdb-check:$7 = 2
37 // gdb-command:print a_struct
38 // gdb-check:$8 = {a = -3, b = 4.5, c = 5}
39 // gdb-command:print *struct_ref
40 // gdb-check:$9 = {a = -3, b = 4.5, c = 5}
41 // gdb-command:print *owned
42 // gdb-check:$10 = 6
43
44
45 // === LLDB TESTS ==================================================================================
46
47 // lldb-command:run
48
49 // lldb-command:print variable
50 // lldb-check:[...]$0 = 1
51 // lldb-command:print constant
52 // lldb-check:[...]$1 = 2
53 // lldb-command:print a_struct
54 // lldb-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 }
55 // lldb-command:print *struct_ref
56 // lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
57 // lldb-command:print *owned
58 // lldb-check:[...]$4 = 6
59
60 // lldb-command:continue
61
62 // lldb-command:print variable
63 // lldb-check:[...]$5 = 2
64 // lldb-command:print constant
65 // lldb-check:[...]$6 = 2
66 // lldb-command:print a_struct
67 // lldb-check:[...]$7 = Struct { a: -3, b: 4.5, c: 5 }
68 // lldb-command:print *struct_ref
69 // lldb-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 }
70 // lldb-command:print *owned
71 // lldb-check:[...]$9 = 6
72
73 #![feature(unboxed_closures)]
74 #![allow(unused_variables)]
75
76 struct Struct {
77     a: int,
78     b: f64,
79     c: uint
80 }
81
82 fn main() {
83     let mut variable = 1;
84     let constant = 2;
85
86     let a_struct = Struct {
87         a: -3,
88         b: 4.5,
89         c: 5
90     };
91
92     let struct_ref = &a_struct;
93     let owned = box 6;
94
95     {
96         let closure = || {
97             zzz(); // #break
98             variable = constant + a_struct.a + struct_ref.a + *owned;
99         };
100
101         closure();
102     }
103
104     {
105         let mut unboxed_closure = |&mut:| {
106             zzz(); // #break
107             variable = constant + a_struct.a + struct_ref.a + *owned;
108         };
109         unboxed_closure();
110     }
111 }
112
113 fn zzz() {()}