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-test FIXME(#16919)
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
23 // The following line actually doesn't have to do anything with pretty printing,
24 // it just tells GDB to print values on one line:
25 // gdb-command: set print pretty off
27 // gdb-command: rbreak zzz
29 // gdb-command: finish
31 // gdb-command: print regular_struct
32 // 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..."}
34 // gdb-command: print tuple
35 // gdb-check:$2 = {true, 103, "blub"}
37 // gdb-command: print tuple_struct
38 // gdb-check:$3 = TupleStruct = {-104.5, 105}
40 // gdb-command: print empty_struct
41 // gdb-check:$4 = EmptyStruct
43 // gdb-command: print c_style_enum1
44 // gdb-check:$5 = CStyleEnumVar1
46 // gdb-command: print c_style_enum2
47 // gdb-check:$6 = CStyleEnumVar2
49 // gdb-command: print c_style_enum3
50 // gdb-check:$7 = CStyleEnumVar3
52 // gdb-command: print mixed_enum_c_style_var
53 // gdb-check:$8 = MixedEnumCStyleVar
55 // gdb-command: print mixed_enum_tuple_var
56 // gdb-check:$9 = MixedEnumTupleVar = {106, 107, false}
58 // gdb-command: print mixed_enum_struct_var
59 // gdb-check:$10 = MixedEnumStructVar = {field1 = 108.5, field2 = 109}
61 // gdb-command: print some
62 // gdb-check:$11 = Some = {110}
64 // gdb-command: print none
65 // gdb-check:$12 = None
67 // gdb-command: print nested_variant1
68 // 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}}}
70 // gdb-command: print nested_variant2
71 // 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}}}
73 #![feature(struct_variant)]
75 struct RegularStruct {
77 the_second_field: f64,
78 the_third_field: bool,
79 the_fourth_field: &'static str,
82 struct TupleStruct(f64, i16);
94 MixedEnumTupleVar(u32, u16, bool),
95 MixedEnumStructVar { field1: f64, field2: i32 }
99 regular_struct: RegularStruct,
100 tuple_struct: TupleStruct,
101 empty_struct: EmptyStruct,
102 c_style_enum: CStyleEnum,
103 mixed_enum: MixedEnum,
107 NestedVariant1(NestedStruct),
108 NestedVariant2 { abc: NestedStruct }
113 let regular_struct = RegularStruct {
114 the_first_field: 101,
115 the_second_field: 102.5,
116 the_third_field: false,
117 the_fourth_field: "I'm so pretty, oh so pretty..."
120 let tuple = ( true, 103u32, "blub" );
122 let tuple_struct = TupleStruct(-104.5, 105);
124 let empty_struct = EmptyStruct;
126 let c_style_enum1 = CStyleEnumVar1;
127 let c_style_enum2 = CStyleEnumVar2;
128 let c_style_enum3 = CStyleEnumVar3;
130 let mixed_enum_c_style_var = MixedEnumCStyleVar;
131 let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false);
132 let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 };
134 let some = Some(110u);
135 let none: Option<int> = None;
137 let nested_variant1 = NestedVariant1(
139 regular_struct: RegularStruct {
140 the_first_field: 111,
141 the_second_field: 112.5,
142 the_third_field: true,
143 the_fourth_field: "NestedStructString1",
145 tuple_struct: TupleStruct(113.5, 114),
146 empty_struct: EmptyStruct,
147 c_style_enum: CStyleEnumVar2,
148 mixed_enum: MixedEnumTupleVar(115, 116, false)
152 let nested_variant2 = NestedVariant2 {
154 regular_struct: RegularStruct {
155 the_first_field: 117,
156 the_second_field: 118.5,
157 the_third_field: false,
158 the_fourth_field: "NestedStructString10",
160 tuple_struct: TupleStruct(119.5, 120),
161 empty_struct: EmptyStruct,
162 c_style_enum: CStyleEnumVar3,
163 mixed_enum: MixedEnumStructVar {