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 "" {...@@ -2702,5 +2702,5 @@ test "" {
2702 // The only purpose of this test is to get all these untested functions2702 // The only purpose of this test is to get all these untested functions
2703 // to be referenced to avoid regression so it is okay to skip some targets.2703 // to be referenced to avoid regression so it is okay to skip some targets.
2704 if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64)2704 if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64)
2705 std.meta.refAllDecls(@This());2705 std.testing.refAllDecls(@This());
2706}2706}
lib/std/build/emit_raw.zig+1-1
...@@ -224,5 +224,5 @@ pub const InstallRawStep = struct {...@@ -224,5 +224,5 @@ pub const InstallRawStep = struct {
224};224};
225225
226test "" {226test "" {
227 std.meta.refAllDecls(InstallRawStep);227 std.testing.refAllDecls(InstallRawStep);
228}228}
lib/std/crypto.zig+1-1
...@@ -110,7 +110,7 @@ test "crypto" {...@@ -110,7 +110,7 @@ test "crypto" {
110 inline for (std.meta.declarations(@This())) |decl| {110 inline for (std.meta.declarations(@This())) |decl| {
111 switch (decl.data) {111 switch (decl.data) {
112 .Type => |t| {112 .Type => |t| {
113 std.meta.refAllDecls(t);113 std.testing.refAllDecls(t);
114 },114 },
115 .Var => |v| {115 .Var => |v| {
116 _ = v;116 _ = v;
lib/std/math.zig+1-1
...@@ -194,7 +194,7 @@ pub const Complex = complex.Complex;...@@ -194,7 +194,7 @@ pub const Complex = complex.Complex;
194pub const big = @import("math/big.zig");194pub const big = @import("math/big.zig");
195195
196test "" {196test "" {
197 std.meta.refAllDecls(@This());197 std.testing.refAllDecls(@This());
198}198}
199199
200pub fn floatMantissaBits(comptime T: type) comptime_int {200pub 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 {...@@ -655,13 +655,7 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
655 return null;655 return null;
656}656}
657657
658/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them.658pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta to std.testing");
659pub fn refAllDecls(comptime T: type) void {
660 if (!builtin.is_test) return;
661 inline for (declarations(T)) |decl| {
662 _ = decl;
663 }
664}
665659
666/// Returns a slice of pointers to public declarations of a namespace.660/// Returns a slice of pointers to public declarations of a namespace.
667pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {661pub 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 {...@@ -1140,5 +1140,5 @@ fn testRangeBias(r: *Random, start: i8, end: i8, biased: bool) void {
1140}1140}
11411141
1142test "" {1142test "" {
1143 std.meta.refAllDecls(@This());1143 std.testing.refAllDecls(@This());
1144}1144}
lib/std/std.zig+1-1
...@@ -92,5 +92,5 @@ comptime {...@@ -92,5 +92,5 @@ comptime {
92}92}
9393
94test "" {94test "" {
95 meta.refAllDecls(@This());95 testing.refAllDecls(@This());
96}96}
lib/std/target.zig+1-1
...@@ -1516,5 +1516,5 @@ pub const Target = struct {...@@ -1516,5 +1516,5 @@ pub const Target = struct {
1516};1516};
15171517
1518test "" {1518test "" {
1519 std.meta.refAllDecls(Target.Cpu.Arch);1519 std.testing.refAllDecls(Target.Cpu.Arch);
1520}1520}
lib/std/testing.zig+8
...@@ -389,3 +389,11 @@ fn printLine(line: []const u8) void {...@@ -389,3 +389,11 @@ fn printLine(line: []const u8) void {
389test "" {389test "" {
390 expectEqualStrings("foo", "foo");390 expectEqualStrings("foo", "foo");
391}391}
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" {...@@ -255,5 +255,5 @@ test "parseCharLiteral" {
255}255}
256256
257test "" {257test "" {
258 @import("std").meta.refAllDecls(@This());258 @import("std").testing.refAllDecls(@This());
259}259}