| ... | ... | @@ -1,10 +1,13 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | | const expect = std.testing.expect; |
| 2 | const builtin = std.builtin; |
| 3 | 3 | const mem = std.mem; |
| 4 | | const builtin = @import("builtin"); |
| 4 | |
| 5 | 5 | const TypeInfo = builtin.TypeInfo; |
| 6 | 6 | const TypeId = builtin.TypeId; |
| 7 | 7 | |
| 8 | const expect = std.testing.expect; |
| 9 | const expectEqualStrings = std.testing.expectEqualStrings; |
| 10 | |
| 8 | 11 | test "type info: tag type, void info" { |
| 9 | 12 | testBasic(); |
| 10 | 13 | comptime testBasic(); |
| ... | ... | @@ -232,10 +235,14 @@ test "type info: struct info" { |
| 232 | 235 | |
| 233 | 236 | fn testStruct() void { |
| 234 | 237 | const unpacked_struct_info = @typeInfo(TestUnpackedStruct); |
| 238 | expect(unpacked_struct_info.Struct.is_tuple == false); |
| 235 | 239 | expect(unpacked_struct_info.Struct.fields[0].alignment == @alignOf(u32)); |
| 240 | expect(unpacked_struct_info.Struct.fields[0].default_value.? == 4); |
| 241 | expectEqualStrings("foobar", unpacked_struct_info.Struct.fields[1].default_value.?); |
| 236 | 242 | |
| 237 | 243 | const struct_info = @typeInfo(TestStruct); |
| 238 | 244 | expect(struct_info == .Struct); |
| 245 | expect(struct_info.Struct.is_tuple == false); |
| 239 | 246 | expect(struct_info.Struct.layout == .Packed); |
| 240 | 247 | expect(struct_info.Struct.fields.len == 4); |
| 241 | 248 | expect(struct_info.Struct.fields[0].alignment == 2 * @alignOf(usize)); |
| ... | ... | @@ -253,6 +260,7 @@ fn testStruct() void { |
| 253 | 260 | |
| 254 | 261 | const TestUnpackedStruct = struct { |
| 255 | 262 | fieldA: u32 = 4, |
| 263 | fieldB: *const [6:0]u8 = "foobar", |
| 256 | 264 | }; |
| 257 | 265 | |
| 258 | 266 | const TestStruct = packed struct { |
| ... | ... | @@ -371,7 +379,7 @@ test "type info: extern fns with and without lib names" { |
| 371 | 379 | if (std.mem.eql(u8, decl.name, "bar1")) { |
| 372 | 380 | expect(decl.data.Fn.lib_name == null); |
| 373 | 381 | } else { |
| 374 | | std.testing.expectEqual(@as([]const u8, "cool"), decl.data.Fn.lib_name.?); |
| 382 | expectEqualStrings("cool", decl.data.Fn.lib_name.?); |
| 375 | 383 | } |
| 376 | 384 | } |
| 377 | 385 | } |