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