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 // The following line actually doesn't have to do anything with pretty printing,
18 // it just tells GDB to print values on one line:
19 // gdb-command: set print pretty off
21 // gdb-command: rbreak zzz
23 // gdb-command: finish
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 #![feature(struct_variant)]
69 struct RegularStruct {
71 the_second_field: f64,
72 the_third_field: bool,
73 the_fourth_field: &'static str,
76 struct TupleStruct(f64, i16);
88 MixedEnumTupleVar(u32, u16, bool),
89 MixedEnumStructVar { field1: f64, field2: i32 }
93 regular_struct: RegularStruct,
94 tuple_struct: TupleStruct,
95 empty_struct: EmptyStruct,
96 c_style_enum: CStyleEnum,
97 mixed_enum: MixedEnum,
101 NestedVariant1(NestedStruct),
102 NestedVariant2 { abc: NestedStruct }
107 let regular_struct = RegularStruct {
108 the_first_field: 101,
109 the_second_field: 102.5,
110 the_third_field: false,
111 the_fourth_field: "I'm so pretty, oh so pretty..."
114 let tuple = ( true, 103u32, "blub" );
116 let tuple_struct = TupleStruct(-104.5, 105);
118 let empty_struct = EmptyStruct;
120 let c_style_enum1 = CStyleEnumVar1;
121 let c_style_enum2 = CStyleEnumVar2;
122 let c_style_enum3 = CStyleEnumVar3;
124 let mixed_enum_c_style_var = MixedEnumCStyleVar;
125 let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false);
126 let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 };
128 let some = Some(110u);
129 let none: Option<int> = None;
131 let nested_variant1 = NestedVariant1(
133 regular_struct: RegularStruct {
134 the_first_field: 111,
135 the_second_field: 112.5,
136 the_third_field: true,
137 the_fourth_field: "NestedStructString1",
139 tuple_struct: TupleStruct(113.5, 114),
140 empty_struct: EmptyStruct,
141 c_style_enum: CStyleEnumVar2,
142 mixed_enum: MixedEnumTupleVar(115, 116, false)
146 let nested_variant2 = NestedVariant2 {
148 regular_struct: RegularStruct {
149 the_first_field: 117,
150 the_second_field: 118.5,
151 the_third_field: false,
152 the_fourth_field: "NestedStructString10",
154 tuple_struct: TupleStruct(119.5, 120),
155 empty_struct: EmptyStruct,
156 c_style_enum: CStyleEnumVar3,
157 mixed_enum: MixedEnumStructVar {