mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
update test-link to new std.Io API
This commit is contained in:
parent
e9da2783ce
commit
6ece10f63d
9 changed files with 29 additions and 10 deletions
|
|
@ -4,7 +4,7 @@ const std = @import("std");
|
|||
var buffer: [0x1000000]u64 = [1]u64{0} ** 0x1000000;
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
|
||||
|
||||
buffer[0x10] = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -1323,7 +1323,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
|
|||
\\extern var live_var2: i32;
|
||||
\\extern fn live_fn2() void;
|
||||
\\pub fn main() void {
|
||||
\\ var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
\\ var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
|
||||
\\ stdout_writer.interface.print("{d} {d}\n", .{ live_var1, live_var2 }) catch @panic("fail");
|
||||
\\ live_fn2();
|
||||
\\}
|
||||
|
|
@ -1365,7 +1365,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
|
|||
\\extern var live_var2: i32;
|
||||
\\extern fn live_fn2() void;
|
||||
\\pub fn main() void {
|
||||
\\ var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
\\ var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
|
||||
\\ stdout_writer.interface.print("{d} {d}\n", .{ live_var1, live_var2 }) catch @panic("fail");
|
||||
\\ live_fn2();
|
||||
\\}
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ fn testHelloZig(b: *Build, opts: Options) *Step {
|
|||
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
|
||||
\\const std = @import("std");
|
||||
\\pub fn main() void {
|
||||
\\ std.Io.File.stdout().writeAll("Hello world!\n") catch @panic("fail");
|
||||
\\ std.Io.File.stdout().writeStreamingAll(std.Options.debug_io, "Hello world!\n") catch @panic("fail");
|
||||
\\}
|
||||
});
|
||||
|
||||
|
|
@ -2372,7 +2372,7 @@ fn testTlsZig(b: *Build, opts: Options) *Step {
|
|||
\\threadlocal var x: i32 = 0;
|
||||
\\threadlocal var y: i32 = -1;
|
||||
\\pub fn main() void {
|
||||
\\ var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
\\ var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
|
||||
\\ stdout_writer.interface.print("{d} {d}\n", .{x, y}) catch unreachable;
|
||||
\\ x -= 1;
|
||||
\\ y += 1;
|
||||
|
|
|
|||
2
test/link/wasm/extern/main.zig
vendored
2
test/link/wasm/extern/main.zig
vendored
|
|
@ -3,6 +3,6 @@ const std = @import("std");
|
|||
extern const foo: u32;
|
||||
|
||||
pub fn main() void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
|
||||
stdout_writer.interface.print("Result: {d}", .{foo}) catch {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
|
||||
// See https://github.com/ziglang/zig/issues/24510
|
||||
// for the plan to simplify this code.
|
||||
pub fn main() !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
|
||||
defer _ = debug_allocator.deinit();
|
||||
const gpa = debug_allocator.allocator();
|
||||
|
||||
var threaded: std.Io.Threaded = .init(gpa, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
const out = &stdout_writer.interface;
|
||||
const stdin: std.Io.File = .stdin();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
const std = @import("std");
|
||||
|
||||
// See https://github.com/ziglang/zig/issues/24510
|
||||
// for the plan to simplify this code.
|
||||
pub fn main() !void {
|
||||
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
|
||||
defer _ = debug_allocator.deinit();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ pub fn main() !void {
|
|||
defer arena_state.deinit();
|
||||
const arena = arena_state.allocator();
|
||||
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
const io = std.Options.debug_io;
|
||||
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
const stdout = &stdout_writer.interface;
|
||||
var args = try std.process.argsAlloc(arena);
|
||||
for (args[1..], 1..) |arg, i| {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,14 @@ pub fn main() !void {
|
|||
|
||||
if (args.len < 3) return error.MissingArgs;
|
||||
|
||||
var threaded: std.Io.Threaded = .init(allocator, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
const relative = try std.fs.path.relative(allocator, args[1], args[2]);
|
||||
defer allocator.free(relative);
|
||||
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
const stdout = &stdout_writer.interface;
|
||||
try stdout.writeAll(relative);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
const io = std.Options.debug_io;
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
const stdout = &stdout_writer.interface;
|
||||
try stdout.writeAll("hello from exe\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue