diff options
| author | Vexu <git@vexu.eu> | 2020-07-11 19:51:20 +0300 |
|---|---|---|
| committer | Vexu <git@vexu.eu> | 2020-07-11 19:51:20 +0300 |
| commit | 2e6688ae27389dcb0d72f2a297b44eca95a02516 (patch) | |
| tree | 82e80565957b5c8ee127317bea3e713523332bc7 /test | |
| parent | 2e037fd827487ce94ae0beb313a1f0536085d61e (diff) | |
| download | zig-2e6688ae27389dcb0d72f2a297b44eca95a02516.tar.gz zig-2e6688ae27389dcb0d72f2a297b44eca95a02516.zip | |
Add test for `@typeInfo` declarations showing up in declaration order
Both the stage1 and std lib HashMap implementations now preserve insertion order
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage1/behavior/type_info.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/stage1/behavior/type_info.zig b/test/stage1/behavior/type_info.zig index 2685a3552e..9da1da6e87 100644 --- a/test/stage1/behavior/type_info.zig +++ b/test/stage1/behavior/type_info.zig @@ -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")); +} |
