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.
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.
11 // ignore-windows failing on win32 bot
12 // ignore-tidy-linelength
14 // ignore-android: FIXME(#10381)
16 // gdb-use-pretty-printer
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
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..."}
28 // gdb-command: print tuple
29 // gdb-check:$2 = {true, 103, "blub"}
31 // gdb-command: print tuple_struct
32 // gdb-check:$3 = TupleStruct = {-104.5, 105}
34 // gdb-command: print empty_struct
35 // gdb-check:$4 = EmptyStruct
37 // gdb-command: print c_style_enum1
38 // gdb-check:$5 = CStyleEnumVar1
40 // gdb-command: print c_style_enum2
41 // gdb-check:$6 = CStyleEnumVar2
43 // gdb-command: print c_style_enum3
44 // gdb-check:$7 = CStyleEnumVar3
46 // gdb-command: print mixed_enum_c_style_var
47 // gdb-check:$8 = MixedEnumCStyleVar
49 // gdb-command: print mixed_enum_tuple_var
50 // gdb-check:$9 = MixedEnumTupleVar = {106, 107, false}
52 // gdb-command: print mixed_enum_struct_var
53 // gdb-check:$10 = MixedEnumStructVar = {field1 = 108.5, field2 = 109}
55 // gdb-command: print some
56 // gdb-check:$11 = Some = {110}
58 // gdb-command: print none
59 // gdb-check:$12 = None
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}}}
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}}}
67 use self::CStyleEnum::{CStyleEnumVar1, CStyleEnumVar2, CStyleEnumVar3};
68 use self::MixedEnum::{MixedEnumCStyleVar, MixedEnumTupleVar, MixedEnumStructVar};
69 use self::NestedEnum::{NestedVariant1, NestedVariant2};
71 struct RegularStruct {
73 the_second_field: f64,
74 the_third_field: bool,
75 the_fourth_field: &'static str,
78 struct TupleStruct(f64, i16);
90 MixedEnumTupleVar(u32, u16, bool),
91 MixedEnumStructVar { field1: f64, field2: i32 }
95 regular_struct: RegularStruct,
96 tuple_struct: TupleStruct,
97 empty_struct: EmptyStruct,
98 c_style_enum: CStyleEnum,
99 mixed_enum: MixedEnum,
103 NestedVariant1(NestedStruct),
104 NestedVariant2 { abc: NestedStruct }
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..."
116 let tuple = ( true, 103u32, "blub" );
118 let tuple_struct = TupleStruct(-104.5, 105);
120 let empty_struct = EmptyStruct;
122 let c_style_enum1 = CStyleEnumVar1;
123 let c_style_enum2 = CStyleEnumVar2;
124 let c_style_enum3 = CStyleEnumVar3;
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 };
130 let some = Some(110u);
131 let none: Option<int> = None;
133 let nested_variant1 = NestedVariant1(
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",
141 tuple_struct: TupleStruct(113.5, 114),
142 empty_struct: EmptyStruct,
143 c_style_enum: CStyleEnumVar2,
144 mixed_enum: MixedEnumTupleVar(115, 116, false)
148 let nested_variant2 = NestedVariant2 {
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",
156 tuple_struct: TupleStruct(119.5, 120),
157 empty_struct: EmptyStruct,
158 c_style_enum: CStyleEnumVar3,
159 mixed_enum: MixedEnumStructVar {