aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-07-11 19:51:20 +0300
committerVexu <git@vexu.eu>2020-07-11 19:51:20 +0300
commit2e6688ae27389dcb0d72f2a297b44eca95a02516 (patch)
tree82e80565957b5c8ee127317bea3e713523332bc7 /test
parent2e037fd827487ce94ae0beb313a1f0536085d61e (diff)
downloadzig-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.zig16
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"));
+}