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-tidy-linelength
13 // ignore-android: FIXME(#10381)
15 // gdb-use-pretty-printer
17 // This test uses some GDB Python API features (e.g. accessing anonymous fields)
18 // which are only available in newer GDB version. The following directive will
19 // case the test runner to ignore this test if an older GDB version is used:
20 // min-gdb-version 7.7
22 // The following line actually doesn't have to do anything with pretty printing,
23 // it just tells GDB to print values on one line:
24 // gdb-command: set print pretty off
26 // gdb-command: rbreak zzz
28 // gdb-command: finish
30 // gdb-command: print regular_struct
31 // 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..."}
33 // gdb-command: print tuple
34 // gdb-check:$2 = {true, 103, "blub"}
36 // gdb-command: print tuple_struct
37 // gdb-check:$3 = TupleStruct = {-104.5, 105}
39 // gdb-command: print empty_struct
40 // gdb-check:$4 = EmptyStruct
42 // gdb-command: print c_style_enum1
43 // gdb-check:$5 = CStyleEnumVar1
45 // gdb-command: print c_style_enum2
46 // gdb-check:$6 = CStyleEnumVar2
48 // gdb-command: print c_style_enum3
49 // gdb-check:$7 = CStyleEnumVar3
51 // gdb-command: print mixed_enum_c_style_var
52 // gdb-check:$8 = MixedEnumCStyleVar
54 // gdb-command: print mixed_enum_tuple_var
55 // gdb-check:$9 = MixedEnumTupleVar = {106, 107, false}
57 // gdb-command: print mixed_enum_struct_var
58 // gdb-check:$10 = MixedEnumStructVar = {field1 = 108.5, field2 = 109}
60 // gdb-command: print some
61 // gdb-check:$11 = Some = {110}
63 // gdb-command: print none
64 // gdb-check:$12 = None
66 // gdb-command: print nested_variant1
67 // 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}}}
69 // gdb-command: print nested_variant2
70 // 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}}}
72 #![feature(struct_variant)]
74 struct RegularStruct {
76 the_second_field: f64,
77 the_third_field: bool,
78 the_fourth_field: &'static str,
81 struct TupleStruct(f64, i16);
93 MixedEnumTupleVar(u32, u16, bool),
94 MixedEnumStructVar { field1: f64, field2: i32 }
98 regular_struct: RegularStruct,
99 tuple_struct: TupleStruct,
100 empty_struct: EmptyStruct,
101 c_style_enum: CStyleEnum,
102 mixed_enum: MixedEnum,
106 NestedVariant1(NestedStruct),
107 NestedVariant2 { abc: NestedStruct }
112 let regular_struct = RegularStruct {
113 the_first_field: 101,
114 the_second_field: 102.5,
115 the_third_field: false,
116 the_fourth_field: "I'm so pretty, oh so pretty..."
119 let tuple = ( true, 103u32, "blub" );
121 let tuple_struct = TupleStruct(-104.5, 105);
123 let empty_struct = EmptyStruct;
125 let c_style_enum1 = CStyleEnumVar1;
126 let c_style_enum2 = CStyleEnumVar2;
127 let c_style_enum3 = CStyleEnumVar3;
129 let mixed_enum_c_style_var = MixedEnumCStyleVar;
130 let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false);
131 let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 };
133 let some = Some(110u);
134 let none: Option<int> = None;
136 let nested_variant1 = NestedVariant1(
138 regular_struct: RegularStruct {
139 the_first_field: 111,
140 the_second_field: 112.5,
141 the_third_field: true,
142 the_fourth_field: "NestedStructString1",
144 tuple_struct: TupleStruct(113.5, 114),
145 empty_struct: EmptyStruct,
146 c_style_enum: CStyleEnumVar2,
147 mixed_enum: MixedEnumTupleVar(115, 116, false)
151 let nested_variant2 = NestedVariant2 {
153 regular_struct: RegularStruct {
154 the_first_field: 117,
155 the_second_field: 118.5,
156 the_third_field: false,
157 the_fourth_field: "NestedStructString10",
159 tuple_struct: TupleStruct(119.5, 120),
160 empty_struct: EmptyStruct,
161 c_style_enum: CStyleEnumVar3,
162 mixed_enum: MixedEnumStructVar {