]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/gdb-pretty-struct-and-enums.rs
test: Ignore gdb-pretty-struct-and-enums.rs
[rust.git] / src / test / debuginfo / gdb-pretty-struct-and-enums.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-test also broken on nightly linux distcheck. it's just broken!
12 // ignore-windows failing on win32 bot
13 // ignore-freebsd: output doesn't match
14 // ignore-tidy-linelength
15 // ignore-lldb
16 // ignore-android: FIXME(#10381)
17 // compile-flags:-g
18
19 // This test uses some GDB Python API features (e.g. accessing anonymous fields)
20 // which are only available in newer GDB version. The following directive will
21 // case the test runner to ignore this test if an older GDB version is used:
22 // min-gdb-version 7.7
23
24 // gdb-command: run
25
26 // gdb-command: print regular_struct
27 // gdb-check:$1 = RegularStruct = {the_first_field = 101, the_second_field = 102.5, the_third_field = false, the_fourth_field = "I'm so pretty, oh so pretty..."}
28
29 // gdb-command: print tuple
30 // gdb-check:$2 = {true, 103, "blub"}
31
32 // gdb-command: print tuple_struct
33 // gdb-check:$3 = TupleStruct = {-104.5, 105}
34
35 // gdb-command: print empty_struct
36 // gdb-check:$4 = EmptyStruct
37
38 // gdb-command: print c_style_enum1
39 // gdb-check:$5 = CStyleEnumVar1
40
41 // gdb-command: print c_style_enum2
42 // gdb-check:$6 = CStyleEnumVar2
43
44 // gdb-command: print c_style_enum3
45 // gdb-check:$7 = CStyleEnumVar3
46
47 // gdb-command: print mixed_enum_c_style_var
48 // gdb-check:$8 = MixedEnumCStyleVar
49
50 // gdb-command: print mixed_enum_tuple_var
51 // gdb-check:$9 = MixedEnumTupleVar = {106, 107, false}
52
53 // gdb-command: print mixed_enum_struct_var
54 // gdb-check:$10 = MixedEnumStructVar = {field1 = 108.5, field2 = 109}
55
56 // gdb-command: print some
57 // gdb-check:$11 = Some = {110}
58
59 // gdb-command: print none
60 // gdb-check:$12 = None
61
62 // gdb-command: print some_fat
63 // gdb-check:$13 = Some = {"abc"}
64
65 // gdb-command: print none_fat
66 // gdb-check:$14 = None
67
68 // gdb-command: print nested_variant1
69 // gdb-check:$15 = NestedVariant1 = {NestedStruct = {regular_struct = RegularStruct = {the_first_field = 111, the_second_field = 112.5, the_third_field = true, the_fourth_field = "NestedStructString1"}, tuple_struct = TupleStruct = {113.5, 114}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar2, mixed_enum = MixedEnumTupleVar = {115, 116, false}}}
70
71 // gdb-command: print nested_variant2
72 // gdb-check:$16 = NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}}
73
74 // gdb-command: print none_check1
75 // gdb-check:$17 = None
76
77 // gdb-command: print none_check2
78 // gdb-check:$18 = None
79
80 #![allow(dead_code, unused_variables)]
81
82 use self::CStyleEnum::{CStyleEnumVar1, CStyleEnumVar2, CStyleEnumVar3};
83 use self::MixedEnum::{MixedEnumCStyleVar, MixedEnumTupleVar, MixedEnumStructVar};
84 use self::NestedEnum::{NestedVariant1, NestedVariant2};
85
86 struct RegularStruct {
87     the_first_field: isize,
88     the_second_field: f64,
89     the_third_field: bool,
90     the_fourth_field: &'static str,
91 }
92
93 struct TupleStruct(f64, i16);
94
95 struct EmptyStruct;
96
97 enum CStyleEnum {
98     CStyleEnumVar1,
99     CStyleEnumVar2,
100     CStyleEnumVar3,
101 }
102
103 enum MixedEnum {
104     MixedEnumCStyleVar,
105     MixedEnumTupleVar(u32, u16, bool),
106     MixedEnumStructVar { field1: f64, field2: i32 }
107 }
108
109 struct NestedStruct {
110     regular_struct: RegularStruct,
111     tuple_struct: TupleStruct,
112     empty_struct: EmptyStruct,
113     c_style_enum: CStyleEnum,
114     mixed_enum: MixedEnum,
115 }
116
117 enum NestedEnum {
118     NestedVariant1(NestedStruct),
119     NestedVariant2 { abc: NestedStruct }
120 }
121
122 fn main() {
123
124     let regular_struct = RegularStruct {
125         the_first_field: 101,
126         the_second_field: 102.5,
127         the_third_field: false,
128         the_fourth_field: "I'm so pretty, oh so pretty..."
129     };
130
131     let tuple = ( true, 103u32, "blub" );
132
133     let tuple_struct = TupleStruct(-104.5, 105);
134
135     let empty_struct = EmptyStruct;
136
137     let c_style_enum1 = CStyleEnumVar1;
138     let c_style_enum2 = CStyleEnumVar2;
139     let c_style_enum3 = CStyleEnumVar3;
140
141     let mixed_enum_c_style_var = MixedEnumCStyleVar;
142     let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false);
143     let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 };
144
145     let some = Some(110_usize);
146     let none: Option<isize> = None;
147     let some_fat = Some("abc");
148     let none_fat: Option<&'static str> = None;
149
150     let nested_variant1 = NestedVariant1(
151         NestedStruct {
152             regular_struct: RegularStruct {
153                 the_first_field: 111,
154                 the_second_field: 112.5,
155                 the_third_field: true,
156                 the_fourth_field: "NestedStructString1",
157             },
158             tuple_struct: TupleStruct(113.5, 114),
159             empty_struct: EmptyStruct,
160             c_style_enum: CStyleEnumVar2,
161             mixed_enum: MixedEnumTupleVar(115, 116, false)
162         }
163     );
164
165     let nested_variant2 = NestedVariant2 {
166         abc: NestedStruct {
167             regular_struct: RegularStruct {
168                 the_first_field: 117,
169                 the_second_field: 118.5,
170                 the_third_field: false,
171                 the_fourth_field: "NestedStructString10",
172             },
173             tuple_struct: TupleStruct(119.5, 120),
174             empty_struct: EmptyStruct,
175             c_style_enum: CStyleEnumVar3,
176             mixed_enum: MixedEnumStructVar {
177                 field1: 121.5,
178                 field2: -122
179             }
180         }
181     };
182
183     let none_check1: Option<(usize, Vec<usize>)> = None;
184     let none_check2: Option<String> = None;
185
186     zzz(); // #break
187 }
188
189 fn zzz() { () }