| ... | @@ -0,0 +1,39 @@ |
| 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | const extras = @import("./lib.zig"); |
| 4 | |
| 5 | pub fn expectSimilarType(comptime A: type, comptime B: type) !void { |
| 6 | const info_a = @typeInfo(A); |
| 7 | const info_b = @typeInfo(B); |
| 8 | try std.testing.expect(std.meta.activeTag(info_a) == std.meta.activeTag(info_b)); |
| 9 | |
| 10 | if (info_a == .Struct) { |
| 11 | const info_a_s = info_a.Struct; |
| 12 | const info_b_s = info_b.Struct; |
| 13 | |
| 14 | try std.testing.expect(info_a_s.layout == info_b_s.layout); |
| 15 | try std.testing.expect(info_a_s.is_tuple == info_b_s.is_tuple); |
| 16 | try std.testing.expect(info_a_s.backing_integer == info_b_s.backing_integer); |
| 17 | |
| 18 | for (info_a_s.decls, info_b_s.decls) |da, db| { |
| 19 | try std.testing.expect(std.mem.eql(u8, da.name, db.name)); |
| 20 | } |
| 21 | |
| 22 | inline for (info_a_s.fields, info_b_s.fields) |fa, fb| { |
| 23 | try std.testing.expect(std.mem.eql(u8, fa.name, fb.name)); |
| 24 | try std.testing.expect(fa.type == fb.type); |
| 25 | try std.testing.expect(fa.alignment == fb.alignment); |
| 26 | try std.testing.expect(fa.is_comptime == fb.is_comptime); |
| 27 | } |
| 28 | |
| 29 | return; |
| 30 | } |
| 31 | @compileError("not implemented"); |
| 32 | } |
| 33 | |
| 34 | test { |
| 35 | try expectSimilarType( |
| 36 | struct { a: u32, b: u8, c: u16 }, |
| 37 | struct { a: u32, b: u8, c: u16 }, |
| 38 | ); |
| 39 | } |