authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-13 14:35:49+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-13 14:36:55+02:00
log8937f18a6f8496e011b13cb086b7948b5f1d540e
tree6db21281a31a02c2b5a6b048d891873c6f169e73
parent17822e4a050dcbcf7fe324fcdff68887fee73ff1

std: force refAllDecls to actually resolve all decls

Only about half of the tests in std were actually being run (918 vs 2144).

3 files changed, 14 insertions(+), 10 deletions(-)

lib/std/testing.zig+2
......@@ -466,6 +466,8 @@ test {
466466pub fn refAllDecls(comptime T: type) void {
467467 if (!builtin.is_test) return;
468468 inline for (comptime std.meta.declarations(T)) |decl| {
469 if (decl.is_pub and @typeInfo(@TypeOf(@field(T, decl.name))) == .Struct)
470 _ = @hasDecl(@field(T, decl.name), "foo");
469471 _ = decl;
470472 }
471473}
lib/std/zig/c_translation.zig+1-1
......@@ -166,7 +166,7 @@ pub fn sizeof(target: anytype) usize {
166166 const array_info = @typeInfo(ptr.child).Array;
167167 if ((array_info.child == u8 or array_info.child == u16) and
168168 array_info.sentinel != null and
169 array_info.sentinel.? == 0)
169 @ptrCast(*const array_info.child, array_info.sentinel.?).* == 0)
170170 {
171171 // length of the string plus one for the null terminator.
172172 return (array_info.len + 1) * @sizeOf(array_info.child);
lib/std/zig/parser_test.zig+11-9
......@@ -585,15 +585,6 @@ test "zig fmt: asm expression with comptime content" {
585585 );
586586}
587587
588test "zig fmt: anytype struct field" {
589 try testCanonical(
590 \\pub const Pointer = struct {
591 \\ sentinel: anytype,
592 \\};
593 \\
594 );
595}
596
597588test "zig fmt: array types last token" {
598589 try testCanonical(
599590 \\test {
......@@ -4148,6 +4139,17 @@ test "zig fmt: container doc comments" {
41484139 );
41494140}
41504141
4142test "zig fmt: anytype struct field" {
4143 try testError(
4144 \\pub const Pointer = struct {
4145 \\ sentinel: anytype,
4146 \\};
4147 \\
4148 , &[_]Error{
4149 .expected_type_expr,
4150 });
4151}
4152
41514153test "zig fmt: extern without container keyword returns error" {
41524154 try testError(
41534155 \\const container = extern {};