mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
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.
This commit is contained in:
parent
d045eb7a4a
commit
96bb1137c2
2 changed files with 4 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||||
const expect = std.testing.expect;
|
const expect = std.testing.expect;
|
||||||
const print = std.debug.print;
|
const print = std.debug.print;
|
||||||
|
|
||||||
test "defer unwinding" {
|
pub fn main() void {
|
||||||
print("\n", .{});
|
print("\n", .{});
|
||||||
|
|
||||||
defer {
|
defer {
|
||||||
|
|
@ -19,4 +19,4 @@ test "defer unwinding" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test
|
// exe=succeed
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
test "inline function call" {
|
pub fn main() void {
|
||||||
if (foo(1200, 34) != 1234) {
|
if (foo(1200, 34) != 1234) {
|
||||||
@compileError("bad");
|
@compileError("bad");
|
||||||
}
|
}
|
||||||
|
|
@ -11,4 +11,4 @@ inline fn foo(a: i32, b: i32) i32 {
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test
|
// exe=succeed
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue