Add test for `@typeInfo` declarations showing up in declaration order

Both the stage1 and std lib HashMap implementations now preserve insertion order
master
Vexu 2020-07-11 19:51:20 +03:00
parent 2e037fd827
commit 2e6688ae27
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
1 changed files with 16 additions and 0 deletions

View File

@ -409,3 +409,19 @@ test "type info: value is correctly copied" {
expect(@typeInfo([]u32).Pointer.size == .Slice);
}
}
test "Declarations are returned in declaration order" {
const S = struct {
const a = 1;
const b = 2;
const c = 3;
const d = 4;
const e = 5;
};
const d = @typeInfo(S).Struct.decls;
expect(std.mem.eql(u8, d[0].name, "a"));
expect(std.mem.eql(u8, d[1].name, "b"));
expect(std.mem.eql(u8, d[2].name, "c"));
expect(std.mem.eql(u8, d[3].name, "d"));
expect(std.mem.eql(u8, d[4].name, "e"));
}