| ... | ... | @@ -211,7 +211,9 @@ fn testUnion() void { |
| 211 | 211 | expect(notag_union_info.Union.tag_type == null); |
| 212 | 212 | expect(notag_union_info.Union.layout == .Auto); |
| 213 | 213 | expect(notag_union_info.Union.fields.len == 2); |
| 214 | expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); |
| 214 | 215 | expect(notag_union_info.Union.fields[1].field_type == u32); |
| 216 | expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32)); |
| 215 | 217 | |
| 216 | 218 | const TestExternUnion = extern union { |
| 217 | 219 | foo: *c_void, |
| ... | ... | @@ -229,13 +231,18 @@ test "type info: struct info" { |
| 229 | 231 | } |
| 230 | 232 | |
| 231 | 233 | fn testStruct() void { |
| 234 | const unpacked_struct_info = @typeInfo(TestUnpackedStruct); |
| 235 | expect(unpacked_struct_info.Struct.fields[0].alignment == @alignOf(u32)); |
| 236 | |
| 232 | 237 | const struct_info = @typeInfo(TestStruct); |
| 233 | 238 | expect(struct_info == .Struct); |
| 234 | 239 | expect(struct_info.Struct.layout == .Packed); |
| 235 | 240 | expect(struct_info.Struct.fields.len == 4); |
| 241 | expect(struct_info.Struct.fields[0].alignment == 2 * @alignOf(usize)); |
| 236 | 242 | expect(struct_info.Struct.fields[2].field_type == *TestStruct); |
| 237 | 243 | expect(struct_info.Struct.fields[2].default_value == null); |
| 238 | 244 | expect(struct_info.Struct.fields[3].default_value.? == 4); |
| 245 | expect(struct_info.Struct.fields[3].alignment == 1); |
| 239 | 246 | expect(struct_info.Struct.decls.len == 2); |
| 240 | 247 | expect(struct_info.Struct.decls[0].is_pub); |
| 241 | 248 | expect(!struct_info.Struct.decls[0].data.Fn.is_extern); |
| ... | ... | @@ -244,8 +251,12 @@ fn testStruct() void { |
| 244 | 251 | expect(struct_info.Struct.decls[0].data.Fn.fn_type == fn (*const TestStruct) void); |
| 245 | 252 | } |
| 246 | 253 | |
| 254 | const TestUnpackedStruct = struct { |
| 255 | fieldA: u32 = 4, |
| 256 | }; |
| 257 | |
| 247 | 258 | const TestStruct = packed struct { |
| 248 | | fieldA: usize, |
| 259 | fieldA: usize align(2 * @alignOf(usize)), |
| 249 | 260 | fieldB: void, |
| 250 | 261 | fieldC: *Self, |
| 251 | 262 | fieldD: u32 = 4, |