Commit 2e6688ae27

Vexu <git@vexu.eu>
2020-07-11 18:51:20
Add test for `@typeInfo` declarations showing up in declaration order
Both the stage1 and std lib HashMap implementations now preserve insertion order
1 parent 2e037fd
Changed files (1)
test
stage1
behavior
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"));
+}