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-freebsd: output doesn't match
13 // ignore-tidy-linelength
15 // ignore-android: FIXME(#10381)
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 some_fat
62 // gdb-check:$13 = Some = {"abc"}
64 // gdb-command: print none_fat
65 // gdb-check:$14 = None
67 // gdb-command: print nested_variant1
68 // gdb-check:$15 = 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:$16 = 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 // gdb-command: print none_check1
74 // gdb-check:$17 = None
76 // gdb-command: print none_check2
77 // gdb-check:$18 = None
79 #![allow(dead_code, unused_variables)]
81 use self::CStyleEnum::{CStyleEnumVar1, CStyleEnumVar2, CStyleEnumVar3};
82 use self::MixedEnum::{MixedEnumCStyleVar, MixedEnumTupleVar, MixedEnumStructVar};
83 use self::NestedEnum::{NestedVariant1, NestedVariant2};
85 struct RegularStruct {
86 the_first_field: isize,
87 the_second_field: f64,
88 the_third_field: bool,
89 the_fourth_field: &'static str,
92 struct TupleStruct(f64, i16);
104 MixedEnumTupleVar(u32, u16, bool),
105 MixedEnumStructVar { field1: f64, field2: i32 }
108 struct NestedStruct {
109 regular_struct: RegularStruct,
110 tuple_struct: TupleStruct,
111 empty_struct: EmptyStruct,
112 c_style_enum: CStyleEnum,
113 mixed_enum: MixedEnum,
117 NestedVariant1(NestedStruct),
118 NestedVariant2 { abc: NestedStruct }
123 let regular_struct = RegularStruct {
124 the_first_field: 101,
125 the_second_field: 102.5,
126 the_third_field: false,
127 the_fourth_field: "I'm so pretty, oh so pretty..."
130 let tuple = ( true, 103u32, "blub" );
132 let tuple_struct = TupleStruct(-104.5, 105);
134 let empty_struct = EmptyStruct;
136 let c_style_enum1 = CStyleEnumVar1;
137 let c_style_enum2 = CStyleEnumVar2;
138 let c_style_enum3 = CStyleEnumVar3;
140 let mixed_enum_c_style_var = MixedEnumCStyleVar;
141 let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false);
142 let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 };
144 let some = Some(110_usize);
145 let none: Option<isize> = None;
146 let some_fat = Some("abc");
147 let none_fat: Option<&'static str> = None;
149 let nested_variant1 = NestedVariant1(
151 regular_struct: RegularStruct {
152 the_first_field: 111,
153 the_second_field: 112.5,
154 the_third_field: true,
155 the_fourth_field: "NestedStructString1",
157 tuple_struct: TupleStruct(113.5, 114),
158 empty_struct: EmptyStruct,
159 c_style_enum: CStyleEnumVar2,
160 mixed_enum: MixedEnumTupleVar(115, 116, false)
164 let nested_variant2 = NestedVariant2 {
166 regular_struct: RegularStruct {
167 the_first_field: 117,
168 the_second_field: 118.5,
169 the_third_field: false,
170 the_fourth_field: "NestedStructString10",
172 tuple_struct: TupleStruct(119.5, 120),
173 empty_struct: EmptyStruct,
174 c_style_enum: CStyleEnumVar3,
175 mixed_enum: MixedEnumStructVar {
182 let none_check1: Option<(usize, Vec<usize>)> = None;
183 let none_check2: Option<String> = None;