motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 96bb1137c23688f01283be24ac9b52e1440afded (tree)
parent d045eb7a4af758e3483e5e8fd9bdbe725095fdec
Author: Alex Kladov <aleksey.kladov@gmail.com>
Date:   Mon, 14 Jul 2025 17:32:50 +0100

langref: don't encourage printing to stderr in tests

The rule: `pub fn main` owns file descriptors 0, 1, and 2. If you didn't
write `pub fn main()` it is, in general, not your business to print to
stderr.

Diffstat:
Mdoc/langref/defer_unwind.zig | 4++--
Mdoc/langref/inline_call.zig | 4++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/langref/defer_unwind.zig b/doc/langref/defer_unwind.zig @@ -2,7 +2,7 @@ const std = @import("std"); const expect = std.testing.expect; const print = std.debug.print; -test "defer unwinding" { +pub fn main() void { print("\n", .{}); defer { @@ -19,4 +19,4 @@ test "defer unwinding" { } } -// test +// exe=succeed diff --git a/doc/langref/inline_call.zig b/doc/langref/inline_call.zig @@ -1,6 +1,6 @@ const std = @import("std"); -test "inline function call" { +pub fn main() void { if (foo(1200, 34) != 1234) { @compileError("bad"); } @@ -11,4 +11,4 @@ inline fn foo(a: i32, b: i32) i32 { return a + b; } -// test +// exe=succeed