update standalone and incremental tests to new API

This commit is contained in:
Andrew Kelley
2025-07-07 19:33:20 -07:00
parent c873c2eed9
commit d8e26275f2
72 changed files with 347 additions and 892 deletions

View File

@@ -6,7 +6,7 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(foo);
try std.fs.File.stdout().writeAll(foo);
}
const foo = "good morning\n";
#expect_stdout="good morning\n"
@@ -15,7 +15,7 @@ const foo = "good morning\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(foo);
try std.fs.File.stdout().writeAll(foo);
}
const foo = "good morning\n";
const bar = "good evening\n";
@@ -25,7 +25,7 @@ const bar = "good evening\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(bar);
try std.fs.File.stdout().writeAll(bar);
}
const foo = "good morning\n";
const bar = "good evening\n";
@@ -35,17 +35,17 @@ const bar = "good evening\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(qux);
try std.fs.File.stdout().writeAll(qux);
}
const foo = "good morning\n";
const bar = "good evening\n";
#expect_error=main.zig:3:37: error: use of undeclared identifier 'qux'
#expect_error=main.zig:3:39: error: use of undeclared identifier 'qux'
#update=add missing declaration
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(qux);
try std.fs.File.stdout().writeAll(qux);
}
const foo = "good morning\n";
const bar = "good evening\n";
@@ -56,7 +56,7 @@ const qux = "good night\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(qux);
try std.fs.File.stdout().writeAll(qux);
}
const qux = "good night\n";
#expect_stdout="good night\n"

View File

@@ -6,7 +6,7 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@This().foo);
try std.fs.File.stdout().writeAll(@This().foo);
}
const foo = "good morning\n";
#expect_stdout="good morning\n"
@@ -15,7 +15,7 @@ const foo = "good morning\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@This().foo);
try std.fs.File.stdout().writeAll(@This().foo);
}
const foo = "good morning\n";
const bar = "good evening\n";
@@ -25,7 +25,7 @@ const bar = "good evening\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@This().bar);
try std.fs.File.stdout().writeAll(@This().bar);
}
const foo = "good morning\n";
const bar = "good evening\n";
@@ -35,18 +35,18 @@ const bar = "good evening\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@This().qux);
try std.fs.File.stdout().writeAll(@This().qux);
}
const foo = "good morning\n";
const bar = "good evening\n";
#expect_error=main.zig:3:44: error: root source file struct 'main' has no member named 'qux'
#expect_error=main.zig:3:46: error: root source file struct 'main' has no member named 'qux'
#expect_error=main.zig:1:1: note: struct declared here
#update=add missing declaration
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@This().qux);
try std.fs.File.stdout().writeAll(@This().qux);
}
const foo = "good morning\n";
const bar = "good evening\n";
@@ -57,7 +57,7 @@ const qux = "good night\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@This().qux);
try std.fs.File.stdout().writeAll(@This().qux);
}
const qux = "good night\n";
#expect_stdout="good night\n"

View File

@@ -7,7 +7,7 @@
#file=main.zig
pub fn main() !void {
_ = @import("foo.zig");
try std.io.getStdOut().writeAll("success\n");
try std.fs.File.stdout().writeAll("success\n");
}
const std = @import("std");
#file=foo.zig
@@ -29,7 +29,7 @@ comptime {
#file=main.zig
pub fn main() !void {
//_ = @import("foo.zig");
try std.io.getStdOut().writeAll("success\n");
try std.fs.File.stdout().writeAll("success\n");
}
const std = @import("std");
#expect_stdout="success\n"

View File

@@ -7,7 +7,7 @@
const std = @import("std");
const string = @embedFile("string.txt");
pub fn main() !void {
try std.io.getStdOut().writeAll(string);
try std.fs.File.stdout().writeAll(string);
}
#file=string.txt
Hello, World!
@@ -27,7 +27,7 @@ Hello again, World!
const std = @import("std");
const string = @embedFile("string.txt");
pub fn main() !void {
try std.io.getStdOut().writeAll("a hardcoded string\n");
try std.fs.File.stdout().writeAll("a hardcoded string\n");
}
#expect_stdout="a hardcoded string\n"
@@ -36,7 +36,7 @@ pub fn main() !void {
const std = @import("std");
const string = @embedFile("string.txt");
pub fn main() !void {
try std.io.getStdOut().writeAll(string);
try std.fs.File.stdout().writeAll(string);
}
#expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound

View File

@@ -14,7 +14,8 @@ const Foo = enum(Tag) {
pub fn main() !void {
var val: Foo = undefined;
val = .a;
try std.io.getStdOut().writer().print("{s}\n", .{@tagName(val)});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{s}\n", .{@tagName(val)});
}
const std = @import("std");
#expect_stdout="a\n"
@@ -31,7 +32,8 @@ const Foo = enum(Tag) {
pub fn main() !void {
var val: Foo = undefined;
val = .a;
try std.io.getStdOut().writer().print("{s}\n", .{@tagName(val)});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{s}\n", .{@tagName(val)});
}
comptime {
// These can't be true at the same time; analysis should stop as soon as it sees `Foo`
@@ -53,7 +55,8 @@ const Foo = enum(Tag) {
pub fn main() !void {
var val: Foo = undefined;
val = .a;
try std.io.getStdOut().writer().print("{s}\n", .{@tagName(val)});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{s}\n", .{@tagName(val)});
}
const std = @import("std");
#expect_stdout="a\n"

View File

@@ -16,7 +16,8 @@ pub fn main() !void {
extern const bar: u32;
};
S.foo();
try std.io.getStdOut().writer().print("{}\n", .{S.bar});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{}\n", .{S.bar});
}
const std = @import("std");
#expect_stdout="123\n"
@@ -37,7 +38,8 @@ pub fn main() !void {
extern const other: u32;
};
S.foo();
try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other });
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_error=main.zig:6:5: error: exported symbol collision: foo
@@ -59,7 +61,8 @@ pub fn main() !void {
extern const other: u32;
};
S.foo();
try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other });
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_stdout="123 456\n"
@@ -83,7 +86,8 @@ pub fn main() !void {
extern const other: u32;
};
S.foo();
try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other });
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_stdout="123 456\n"
@@ -128,7 +132,8 @@ pub fn main() !void {
extern const other: u32;
};
S.foo();
try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other });
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_stdout="123 456\n"
@@ -152,7 +157,8 @@ pub fn main() !void {
extern const other: u32;
};
S.foo();
try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other });
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_error=main.zig:5:5: error: exported symbol collision: bar

View File

@@ -7,7 +7,8 @@ pub fn main() !void {
try foo(123);
}
fn foo(x: u8) !void {
return std.io.getStdOut().writer().print("{d}\n", .{x});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
return stdout_writer.interface.print("{d}\n", .{x});
}
const std = @import("std");
#expect_stdout="123\n"
@@ -18,7 +19,8 @@ pub fn main() !void {
try foo(123);
}
fn foo(x: i64) !void {
return std.io.getStdOut().writer().print("{d}\n", .{x});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
return stdout_writer.interface.print("{d}\n", .{x});
}
const std = @import("std");
#expect_stdout="123\n"
@@ -29,7 +31,8 @@ pub fn main() !void {
try foo(-42);
}
fn foo(x: i64) !void {
return std.io.getStdOut().writer().print("{d}\n", .{x});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
return stdout_writer.interface.print("{d}\n", .{x});
}
const std = @import("std");
#expect_stdout="-42\n"

View File

@@ -6,7 +6,7 @@ const std = @import("std");
fn Printer(message: []const u8) type {
return struct {
fn print() !void {
try std.io.getStdOut().writeAll(message);
try std.fs.File.stdout().writeAll(message);
}
};
}
@@ -22,7 +22,7 @@ const std = @import("std");
fn Printer(message: []const u8) type {
return struct {
fn print() !void {
try std.io.getStdOut().writeAll(message);
try std.fs.File.stdout().writeAll(message);
}
};
}

View File

@@ -4,7 +4,7 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("foo\n");
try std.fs.File.stdout().writeAll("foo\n");
}
#expect_stdout="foo\n"
#update=change line number
@@ -12,6 +12,6 @@ pub fn main() !void {
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("foo\n");
try std.fs.File.stdout().writeAll("foo\n");
}
#expect_stdout="foo\n"

View File

@@ -11,7 +11,8 @@ pub fn main() !u8 {
}
pub const panic = std.debug.FullPanic(myPanic);
fn myPanic(msg: []const u8, _: ?usize) noreturn {
std.io.getStdOut().writer().print("panic message: {s}\n", .{msg}) catch {};
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
@@ -27,7 +28,8 @@ pub fn main() !u8 {
}
pub const panic = std.debug.FullPanic(myPanic);
fn myPanic(msg: []const u8, _: ?usize) noreturn {
std.io.getStdOut().writer().print("new panic message: {s}\n", .{msg}) catch {};
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
@@ -43,7 +45,8 @@ pub fn main() !u8 {
}
pub const panic = std.debug.FullPanic(myPanicNew);
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
std.io.getStdOut().writer().print("third panic message: {s}\n", .{msg}) catch {};
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");

View File

@@ -41,7 +41,8 @@ pub const panic = struct {
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanic(msg: []const u8, _: ?usize) noreturn {
std.io.getStdOut().writer().print("panic message: {s}\n", .{msg}) catch {};
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
@@ -87,7 +88,8 @@ pub const panic = struct {
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanic(msg: []const u8, _: ?usize) noreturn {
std.io.getStdOut().writer().print("new panic message: {s}\n", .{msg}) catch {};
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
@@ -133,7 +135,8 @@ pub const panic = struct {
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
std.io.getStdOut().writer().print("third panic message: {s}\n", .{msg}) catch {};
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");

View File

@@ -8,7 +8,8 @@ pub fn main() !void {
try foo(0x1300);
}
fn foo(x: u16) !void {
try std.io.getStdOut().writer().print("0x{x}\n", .{x << 4});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("0x{x}\n", .{x << 4});
}
const std = @import("std");
#expect_stdout="0x3000\n"
@@ -18,7 +19,8 @@ pub fn main() !void {
try foo(0x1300);
}
fn foo(x: u16) !void {
try std.io.getStdOut().writer().print("0x{x}\n", .{x >> 4});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("0x{x}\n", .{x >> 4});
}
const std = @import("std");
#expect_stdout="0x130\n"

View File

@@ -10,7 +10,8 @@ pub fn main() !void {
try foo(&val);
}
fn foo(val: *const S) !void {
try std.io.getStdOut().writer().print(
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print(
"{d} {d}\n",
.{ val.x, val.y },
);
@@ -26,7 +27,8 @@ pub fn main() !void {
try foo(&val);
}
fn foo(val: *const S) !void {
try std.io.getStdOut().writer().print(
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print(
"{d} {d}\n",
.{ val.x, val.y },
);
@@ -42,7 +44,8 @@ pub fn main() !void {
try foo(&val);
}
fn foo(val: *const S) !void {
try std.io.getStdOut().writer().print(
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print(
"{d} {d}\n",
.{ val.x, val.y },
);

View File

@@ -7,7 +7,7 @@
const std = @import("std");
const message: []const u8 = @import("message.zon");
pub fn main() !void {
try std.io.getStdOut().writeAll(message);
try std.fs.File.stdout().writeAll(message);
}
#file=message.zon
"Hello, World!\n"
@@ -28,7 +28,7 @@ pub fn main() !void {
const std = @import("std");
const message: []const u8 = @import("message.zon");
pub fn main() !void {
try std.io.getStdOut().writeAll("a hardcoded string\n");
try std.fs.File.stdout().writeAll("a hardcoded string\n");
}
#expect_error=message.zon:1:1: error: unable to load 'message.zon': FileNotFound
#expect_error=main.zig:2:37: note: file imported here
@@ -43,6 +43,6 @@ pub fn main() !void {
const std = @import("std");
const message: []const u8 = @import("message.zon");
pub fn main() !void {
try std.io.getStdOut().writeAll(message);
try std.fs.File.stdout().writeAll(message);
}
#expect_stdout="We're back, World!\n"

View File

@@ -6,7 +6,7 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(@import("foo.zon").message);
try std.fs.File.stdout().writeAll(@import("foo.zon").message);
}
#file=foo.zon
.{

View File

@@ -7,7 +7,7 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
#expect_stdout="Hello, World!\n"
@@ -15,7 +15,7 @@ pub fn main() !void {
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
@compileLog("this is a log");
}
#expect_error=main.zig:4:5: error: found compile log statement
@@ -25,6 +25,6 @@ pub fn main() !void {
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
#expect_stdout="Hello, World!\n"

View File

@@ -9,28 +9,28 @@ pub fn main() !void {
}
#file=foo.zig
pub fn hello() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
#expect_error=foo.zig:2:9: error: use of undeclared identifier 'std'
#update=fix the error
#file=foo.zig
const std = @import("std");
pub fn hello() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
#expect_stdout="Hello, World!\n"
#update=add new error
#file=foo.zig
const std = @import("std");
pub fn hello() !void {
try std.io.getStdOut().writeAll(hello_str);
try std.fs.File.stdout().writeAll(hello_str);
}
#expect_error=foo.zig:3:37: error: use of undeclared identifier 'hello_str'
#expect_error=foo.zig:3:39: error: use of undeclared identifier 'hello_str'
#update=fix the new error
#file=foo.zig
const std = @import("std");
const hello_str = "Hello, World! Again!\n";
pub fn hello() !void {
try std.io.getStdOut().writeAll(hello_str);
try std.fs.File.stdout().writeAll(hello_str);
}
#expect_stdout="Hello, World! Again!\n"

View File

@@ -7,7 +7,7 @@ pub fn main() !void {
try foo();
}
fn foo() !void {
try std.io.getStdOut().writer().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
const std = @import("std");
#expect_stdout="Hello, World!\n"
@@ -18,7 +18,7 @@ pub fn main() !void {
try foo();
}
inline fn foo() !void {
try std.io.getStdOut().writer().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
const std = @import("std");
#expect_stdout="Hello, World!\n"
@@ -29,7 +29,7 @@ pub fn main() !void {
try foo();
}
inline fn foo() !void {
try std.io.getStdOut().writer().writeAll("Hello, `inline` World!\n");
try std.fs.File.stdout().writeAll("Hello, `inline` World!\n");
}
const std = @import("std");
#expect_stdout="Hello, `inline` World!\n"

View File

@@ -6,13 +6,13 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("good morning\n");
try std.fs.File.stdout().writeAll("good morning\n");
}
#expect_stdout="good morning\n"
#update=change the string
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll("おはようございます\n");
try std.fs.File.stdout().writeAll("おはようございます\n");
}
#expect_stdout="おはようございます\n"

View File

@@ -11,7 +11,7 @@ pub fn main() !void {
#file=foo.zig
const std = @import("std");
fn hello() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
#expect_error=main.zig:3:12: error: 'hello' is not marked 'pub'
#expect_error=foo.zig:2:1: note: declared here
@@ -20,6 +20,6 @@ fn hello() !void {
#file=foo.zig
const std = @import("std");
pub fn hello() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
try std.fs.File.stdout().writeAll("Hello, World!\n");
}
#expect_stdout="Hello, World!\n"

View File

@@ -7,7 +7,7 @@
const std = @import("std");
pub fn main() !void {
const str = getStr();
try std.io.getStdOut().writeAll(str);
try std.fs.File.stdout().writeAll(str);
}
inline fn getStr() []const u8 {
return "foo\n";
@@ -18,7 +18,7 @@ inline fn getStr() []const u8 {
const std = @import("std");
pub fn main() !void {
const str = getStr();
try std.io.getStdOut().writeAll(str);
try std.fs.File.stdout().writeAll(str);
}
inline fn getStr() []const u8 {
return "bar\n";

View File

@@ -6,23 +6,9 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writer().print("{d} {d}\n", .{ foo(), bar() });
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{d} {d}\n", .{ foo(), bar() });
}
fn foo() u32 {
return @src().line;
}
fn bar() u32 {
return 123;
}
#expect_stdout="6 123\n"
#update=add newline
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writer().print("{d} {d}\n", .{ foo(), bar() });
}
fn foo() u32 {
return @src().line;
}
@@ -30,3 +16,19 @@ fn bar() u32 {
return 123;
}
#expect_stdout="7 123\n"
#update=add newline
#file=main.zig
const std = @import("std");
pub fn main() !void {
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{d} {d}\n", .{ foo(), bar() });
}
fn foo() u32 {
return @src().line;
}
fn bar() u32 {
return 123;
}
#expect_stdout="8 123\n"

View File

@@ -7,7 +7,7 @@
const std = @import("std");
var some_enum: enum { first, second } = .first;
pub fn main() !void {
try std.io.getStdOut().writeAll(@tagName(some_enum));
try std.fs.File.stdout().writeAll(@tagName(some_enum));
}
#expect_stdout="first"
#update=no change
@@ -15,6 +15,6 @@ pub fn main() !void {
const std = @import("std");
var some_enum: enum { first, second } = .first;
pub fn main() !void {
try std.io.getStdOut().writeAll(@tagName(some_enum));
try std.fs.File.stdout().writeAll(@tagName(some_enum));
}
#expect_stdout="first"

View File

@@ -8,7 +8,7 @@ pub fn main() !void {
try foo(false);
}
fn foo(recurse: bool) !void {
const stdout = std.io.getStdOut().writer();
const stdout = std.fs.File.stdout();
if (recurse) return foo(true);
try stdout.writeAll("non-recursive path\n");
}
@@ -21,7 +21,7 @@ pub fn main() !void {
try foo(true);
}
fn foo(recurse: bool) !void {
const stdout = std.io.getStdOut().writer();
const stdout = std.fs.File.stdout();
if (recurse) return stdout.writeAll("x==1\n");
try stdout.writeAll("non-recursive path\n");
}

View File

@@ -9,7 +9,8 @@ const MyEnum = enum(u8) {
bar = 2,
};
pub fn main() !void {
try std.io.getStdOut().writer().print("{}\n", .{@intFromEnum(MyEnum.foo)});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{}\n", .{@intFromEnum(MyEnum.foo)});
}
const std = @import("std");
#expect_stdout="1\n"
@@ -20,8 +21,9 @@ const MyEnum = enum(u8) {
bar = 2,
};
pub fn main() !void {
try std.io.getStdOut().writer().print("{}\n", .{@intFromEnum(MyEnum.foo)});
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
try stdout_writer.interface.print("{}\n", .{@intFromEnum(MyEnum.foo)});
}
const std = @import("std");
#expect_error=main.zig:6:73: error: enum 'main.MyEnum' has no member named 'foo'
#expect_error=main.zig:7:69: error: enum 'main.MyEnum' has no member named 'foo'
#expect_error=main.zig:1:16: note: enum declared here

View File

@@ -6,7 +6,7 @@
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(a);
try std.fs.File.stdout().writeAll(a);
}
const a = "Hello, World!\n";
#expect_stdout="Hello, World!\n"
@@ -15,7 +15,7 @@ const a = "Hello, World!\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(a);
try std.fs.File.stdout().writeAll(a);
}
const a = @compileError("bad a");
#expect_error=main.zig:5:11: error: bad a
@@ -24,7 +24,7 @@ const a = @compileError("bad a");
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(b);
try std.fs.File.stdout().writeAll(b);
}
const a = @compileError("bad a");
const b = "Hi there!\n";
@@ -34,7 +34,7 @@ const b = "Hi there!\n";
#file=main.zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writeAll(a);
try std.fs.File.stdout().writeAll(a);
}
const a = "Back to a\n";
const b = @compileError("bad b");