zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit e892ee17e680d12292b971b553b36067ed3bbd74 (tree)
parent 0da027f07819657b6a93da6658e734eb1bdfe74f
Author: Tadeo Kondrak <me@tadeo.ca>
Date:   Mon, 28 Sep 2020 07:29:53 -0600

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

Diffstat:
Mlib/std/build.zig | 2+-
Mlib/std/build/emit_raw.zig | 2+-
Mlib/std/crypto.zig | 2+-
Mlib/std/math.zig | 2+-
Mlib/std/meta.zig | 8+-------
Mlib/std/rand.zig | 2+-
Mlib/std/std.zig | 2+-
Mlib/std/target.zig | 2+-
Mlib/std/testing.zig | 8++++++++
Mlib/std/zig.zig | 2+-
10 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/std/build.zig b/lib/std/build.zig @@ -2702,5 +2702,5 @@ test "" { // The only purpose of this test is to get all these untested functions // to be referenced to avoid regression so it is okay to skip some targets. if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64) - std.meta.refAllDecls(@This()); + std.testing.refAllDecls(@This()); } diff --git a/lib/std/build/emit_raw.zig b/lib/std/build/emit_raw.zig @@ -224,5 +224,5 @@ pub const InstallRawStep = struct { }; test "" { - std.meta.refAllDecls(InstallRawStep); + std.testing.refAllDecls(InstallRawStep); } diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig @@ -110,7 +110,7 @@ test "crypto" { inline for (std.meta.declarations(@This())) |decl| { switch (decl.data) { .Type => |t| { - std.meta.refAllDecls(t); + std.testing.refAllDecls(t); }, .Var => |v| { _ = v; diff --git a/lib/std/math.zig b/lib/std/math.zig @@ -194,7 +194,7 @@ pub const Complex = complex.Complex; pub const big = @import("math/big.zig"); test "" { - std.meta.refAllDecls(@This()); + std.testing.refAllDecls(@This()); } pub fn floatMantissaBits(comptime T: type) comptime_int { diff --git a/lib/std/meta.zig b/lib/std/meta.zig @@ -655,13 +655,7 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { return null; } -/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them. -pub fn refAllDecls(comptime T: type) void { - if (!builtin.is_test) return; - inline for (declarations(T)) |decl| { - _ = decl; - } -} +pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta to std.testing"); /// Returns a slice of pointers to public declarations of a namespace. pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl { diff --git a/lib/std/rand.zig b/lib/std/rand.zig @@ -1140,5 +1140,5 @@ fn testRangeBias(r: *Random, start: i8, end: i8, biased: bool) void { } test "" { - std.meta.refAllDecls(@This()); + std.testing.refAllDecls(@This()); } diff --git a/lib/std/std.zig b/lib/std/std.zig @@ -92,5 +92,5 @@ comptime { } test "" { - meta.refAllDecls(@This()); + testing.refAllDecls(@This()); } diff --git a/lib/std/target.zig b/lib/std/target.zig @@ -1516,5 +1516,5 @@ pub const Target = struct { }; test "" { - std.meta.refAllDecls(Target.Cpu.Arch); + std.testing.refAllDecls(Target.Cpu.Arch); } diff --git a/lib/std/testing.zig b/lib/std/testing.zig @@ -389,3 +389,11 @@ fn printLine(line: []const u8) void { test "" { expectEqualStrings("foo", "foo"); } + +/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them. +pub fn refAllDecls(comptime T: type) void { + if (!@import("builtin").is_test) return; + inline for (std.meta.declarations(T)) |decl| { + _ = decl; + } +} diff --git a/lib/std/zig.zig b/lib/std/zig.zig @@ -255,5 +255,5 @@ test "parseCharLiteral" { } test "" { - @import("std").meta.refAllDecls(@This()); + @import("std").testing.refAllDecls(@This()); }