authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-09-28 07:29:53-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-15 20:34:22-04:00
loge892ee17e680d12292b971b553b36067ed3bbd74
treeea6192e3cc8bf630298f4b26d449899e27151ce7
parent0da027f07819657b6a93da6658e734eb1bdfe74f

std: move std.meta.refAllDecls to std.testing


10 files changed, 17 insertions(+), 15 deletions(-)

lib/std/build.zig+1-1
......@@ -2702,5 +2702,5 @@ test "" {
27022702 // The only purpose of this test is to get all these untested functions
27032703 // to be referenced to avoid regression so it is okay to skip some targets.
27042704 if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64)
2705 std.meta.refAllDecls(@This());
2705 std.testing.refAllDecls(@This());
27062706}
lib/std/build/emit_raw.zig+1-1
......@@ -224,5 +224,5 @@ pub const InstallRawStep = struct {
224224};
225225
226226test "" {
227 std.meta.refAllDecls(InstallRawStep);
227 std.testing.refAllDecls(InstallRawStep);
228228}
lib/std/crypto.zig+1-1
......@@ -110,7 +110,7 @@ test "crypto" {
110110 inline for (std.meta.declarations(@This())) |decl| {
111111 switch (decl.data) {
112112 .Type => |t| {
113 std.meta.refAllDecls(t);
113 std.testing.refAllDecls(t);
114114 },
115115 .Var => |v| {
116116 _ = v;
lib/std/math.zig+1-1
......@@ -194,7 +194,7 @@ pub const Complex = complex.Complex;
194194pub const big = @import("math/big.zig");
195195
196196test "" {
197 std.meta.refAllDecls(@This());
197 std.testing.refAllDecls(@This());
198198}
199199
200200pub fn floatMantissaBits(comptime T: type) comptime_int {
lib/std/meta.zig+1-7
......@@ -655,13 +655,7 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
655655 return null;
656656}
657657
658/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them.
659pub fn refAllDecls(comptime T: type) void {
660 if (!builtin.is_test) return;
661 inline for (declarations(T)) |decl| {
662 _ = decl;
663 }
664}
658pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta to std.testing");
665659
666660/// Returns a slice of pointers to public declarations of a namespace.
667661pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {
lib/std/rand.zig+1-1
......@@ -1140,5 +1140,5 @@ fn testRangeBias(r: *Random, start: i8, end: i8, biased: bool) void {
11401140}
11411141
11421142test "" {
1143 std.meta.refAllDecls(@This());
1143 std.testing.refAllDecls(@This());
11441144}
lib/std/std.zig+1-1
......@@ -92,5 +92,5 @@ comptime {
9292}
9393
9494test "" {
95 meta.refAllDecls(@This());
95 testing.refAllDecls(@This());
9696}
lib/std/target.zig+1-1
......@@ -1516,5 +1516,5 @@ pub const Target = struct {
15161516};
15171517
15181518test "" {
1519 std.meta.refAllDecls(Target.Cpu.Arch);
1519 std.testing.refAllDecls(Target.Cpu.Arch);
15201520}
lib/std/testing.zig+8
......@@ -389,3 +389,11 @@ fn printLine(line: []const u8) void {
389389test "" {
390390 expectEqualStrings("foo", "foo");
391391}
392
393/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them.
394pub fn refAllDecls(comptime T: type) void {
395 if (!@import("builtin").is_test) return;
396 inline for (std.meta.declarations(T)) |decl| {
397 _ = decl;
398 }
399}
lib/std/zig.zig+1-1
......@@ -255,5 +255,5 @@ test "parseCharLiteral" {
255255}
256256
257257test "" {
258 @import("std").meta.refAllDecls(@This());
258 @import("std").testing.refAllDecls(@This());
259259}