mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:04:43 +01:00
update all incremental tests to new std API
they're still not passing on windows for some reason though
This commit is contained in:
parent
77d2ad8c92
commit
debf307594
26 changed files with 155 additions and 80 deletions
|
|
@ -7,57 +7,63 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(foo);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, foo);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good morning\n"
|
||||
|
||||
#update=add new declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(foo);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, foo);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good morning\n"
|
||||
|
||||
#update=reference new declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(bar);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, bar);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good evening\n"
|
||||
|
||||
#update=reference missing declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(qux);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, qux);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
#expect_error=main.zig:3:39: error: use of undeclared identifier 'qux'
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:3:52: error: use of undeclared identifier 'qux'
|
||||
|
||||
#update=add missing declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(qux);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, qux);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
const qux = "good night\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good night\n"
|
||||
|
||||
#update=remove unused declarations
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(qux);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, qux);
|
||||
}
|
||||
const qux = "good night\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good night\n"
|
||||
|
|
|
|||
|
|
@ -7,58 +7,64 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(@This().foo);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @This().foo);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good morning\n"
|
||||
|
||||
#update=add new declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(@This().foo);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @This().foo);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good morning\n"
|
||||
|
||||
#update=reference new declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(@This().bar);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @This().bar);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good evening\n"
|
||||
|
||||
#update=reference missing declaration
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(@This().qux);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @This().qux);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
#expect_error=main.zig:3:46: error: root source file struct 'main' has no member named 'qux'
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:3:59: 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.File.stdout().writeAll(@This().qux);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @This().qux);
|
||||
}
|
||||
const foo = "good morning\n";
|
||||
const bar = "good evening\n";
|
||||
const qux = "good night\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good night\n"
|
||||
|
||||
#update=remove unused declarations
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(@This().qux);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @This().qux);
|
||||
}
|
||||
const qux = "good night\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="good night\n"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@
|
|||
#file=main.zig
|
||||
pub fn main() !void {
|
||||
_ = @import("foo.zig");
|
||||
try std.Io.File.stdout().writeAll("success\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "success\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#file=foo.zig
|
||||
comptime {
|
||||
_ = @import("bad.zig");
|
||||
|
|
@ -30,7 +31,8 @@ comptime {
|
|||
#file=main.zig
|
||||
pub fn main() !void {
|
||||
//_ = @import("foo.zig");
|
||||
try std.Io.File.stdout().writeAll("success\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "success\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="success\n"
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
const std = @import("std");
|
||||
const string = @embedFile("string.txt");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(string);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, string);
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#file=string.txt
|
||||
Hello, World!
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
|
@ -28,8 +29,9 @@ Hello again, World!
|
|||
const std = @import("std");
|
||||
const string = @embedFile("string.txt");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("a hardcoded string\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "a hardcoded string\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="a hardcoded string\n"
|
||||
|
||||
#update=re-introduce reference to file
|
||||
|
|
@ -37,8 +39,9 @@ pub fn main() !void {
|
|||
const std = @import("std");
|
||||
const string = @embedFile("string.txt");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(string);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, string);
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound
|
||||
|
||||
#update=recreate file
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ const Foo = enum(Tag) {
|
|||
pub fn main() !void {
|
||||
var val: Foo = undefined;
|
||||
val = .a;
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{s}\n", .{@tagName(val)});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="a\n"
|
||||
#update=too many enum fields
|
||||
#file=main.zig
|
||||
|
|
@ -33,7 +34,7 @@ const Foo = enum(Tag) {
|
|||
pub fn main() !void {
|
||||
var val: Foo = undefined;
|
||||
val = .a;
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{s}\n", .{@tagName(val)});
|
||||
}
|
||||
comptime {
|
||||
|
|
@ -42,6 +43,7 @@ comptime {
|
|||
std.debug.assert(@TypeOf(@intFromEnum(Foo.e)) == Tag);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:7:5: error: enumeration value '4' too large for type 'u2'
|
||||
#update=increase tag size
|
||||
#file=main.zig
|
||||
|
|
@ -56,8 +58,9 @@ const Foo = enum(Tag) {
|
|||
pub fn main() !void {
|
||||
var val: Foo = undefined;
|
||||
val = .a;
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{s}\n", .{@tagName(val)});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="a\n"
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@ pub fn main() !void {
|
|||
extern const bar: u32;
|
||||
};
|
||||
S.foo();
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{}\n", .{S.bar});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="123\n"
|
||||
|
||||
#update=add conflict
|
||||
|
|
@ -39,10 +40,11 @@ pub fn main() !void {
|
|||
extern const other: u32;
|
||||
};
|
||||
S.foo();
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:6:5: error: exported symbol collision: foo
|
||||
#expect_error=main.zig:1:1: note: other symbol here
|
||||
|
||||
|
|
@ -62,10 +64,11 @@ pub fn main() !void {
|
|||
extern const other: u32;
|
||||
};
|
||||
S.foo();
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="123 456\n"
|
||||
|
||||
#update=put exports in decl
|
||||
|
|
@ -87,10 +90,11 @@ pub fn main() !void {
|
|||
extern const other: u32;
|
||||
};
|
||||
S.foo();
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="123 456\n"
|
||||
|
||||
#update=remove reference to exporting decl
|
||||
|
|
@ -133,10 +137,11 @@ pub fn main() !void {
|
|||
extern const other: u32;
|
||||
};
|
||||
S.foo();
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="123 456\n"
|
||||
|
||||
#update=reintroduce reference to exporting decl, introducing conflict
|
||||
|
|
@ -158,10 +163,11 @@ pub fn main() !void {
|
|||
extern const other: u32;
|
||||
};
|
||||
S.foo();
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:5:5: error: exported symbol collision: bar
|
||||
#expect_error=main.zig:2:1: note: other symbol here
|
||||
#expect_error=main.zig:6:5: error: exported symbol collision: other
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ pub fn main() !void {
|
|||
try foo(123);
|
||||
}
|
||||
fn foo(x: u8) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
return stdout_writer.interface.print("{d}\n", .{x});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="123\n"
|
||||
|
||||
#update=change function type
|
||||
|
|
@ -20,10 +21,11 @@ pub fn main() !void {
|
|||
try foo(123);
|
||||
}
|
||||
fn foo(x: i64) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
return stdout_writer.interface.print("{d}\n", .{x});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="123\n"
|
||||
|
||||
#update=change function argument
|
||||
|
|
@ -32,8 +34,9 @@ pub fn main() !void {
|
|||
try foo(-42);
|
||||
}
|
||||
fn foo(x: i64) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
return stdout_writer.interface.print("{d}\n", .{x});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="-42\n"
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@
|
|||
#update=initial version
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
fn Printer(message: []const u8) type {
|
||||
return struct {
|
||||
fn print() !void {
|
||||
try std.Io.File.stdout().writeAll(message);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -19,11 +20,12 @@ pub fn main() !void {
|
|||
#update=change line number
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
|
||||
fn Printer(message: []const u8) type {
|
||||
return struct {
|
||||
fn print() !void {
|
||||
try std.Io.File.stdout().writeAll(message);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("foo\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "foo\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="foo\n"
|
||||
#update=change line number
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("foo\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "foo\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="foo\n"
|
||||
|
|
|
|||
|
|
@ -12,11 +12,12 @@ pub fn main() !u8 {
|
|||
}
|
||||
pub const panic = std.debug.FullPanic(myPanic);
|
||||
fn myPanic(msg: []const u8, _: ?usize) noreturn {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
|
||||
std.process.exit(0);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="panic message: integer overflow\n"
|
||||
|
||||
#update=change the panic handler body
|
||||
|
|
@ -29,11 +30,12 @@ pub fn main() !u8 {
|
|||
}
|
||||
pub const panic = std.debug.FullPanic(myPanic);
|
||||
fn myPanic(msg: []const u8, _: ?usize) noreturn {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
|
||||
std.process.exit(0);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="new panic message: integer overflow\n"
|
||||
|
||||
#update=change the panic handler function value
|
||||
|
|
@ -46,9 +48,10 @@ pub fn main() !u8 {
|
|||
}
|
||||
pub const panic = std.debug.FullPanic(myPanicNew);
|
||||
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
|
||||
std.process.exit(0);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="third panic message: integer overflow\n"
|
||||
|
|
|
|||
|
|
@ -42,11 +42,12 @@ pub const panic = struct {
|
|||
pub const noreturnReturned = no_panic.noreturnReturned;
|
||||
};
|
||||
fn myPanic(msg: []const u8, _: ?usize) noreturn {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
|
||||
std.process.exit(0);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="panic message: integer overflow\n"
|
||||
|
||||
#update=change the panic handler body
|
||||
|
|
@ -89,11 +90,12 @@ pub const panic = struct {
|
|||
pub const noreturnReturned = no_panic.noreturnReturned;
|
||||
};
|
||||
fn myPanic(msg: []const u8, _: ?usize) noreturn {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
|
||||
std.process.exit(0);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="new panic message: integer overflow\n"
|
||||
|
||||
#update=change the panic handler function value
|
||||
|
|
@ -136,9 +138,10 @@ pub const panic = struct {
|
|||
pub const noreturnReturned = no_panic.noreturnReturned;
|
||||
};
|
||||
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
|
||||
std.process.exit(0);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="third panic message: integer overflow\n"
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ pub fn main() !void {
|
|||
try foo(0x1300);
|
||||
}
|
||||
fn foo(x: u16) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("0x{x}\n", .{x << 4});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="0x3000\n"
|
||||
#update=change to right shift
|
||||
#file=main.zig
|
||||
|
|
@ -20,8 +21,9 @@ pub fn main() !void {
|
|||
try foo(0x1300);
|
||||
}
|
||||
fn foo(x: u16) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("0x{x}\n", .{x >> 4});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="0x130\n"
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ pub fn main() !void {
|
|||
try foo(&val);
|
||||
}
|
||||
fn foo(val: *const S) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print(
|
||||
"{d} {d}\n",
|
||||
.{ val.x, val.y },
|
||||
);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="100 200\n"
|
||||
|
||||
#update=change struct layout
|
||||
|
|
@ -28,13 +29,14 @@ pub fn main() !void {
|
|||
try foo(&val);
|
||||
}
|
||||
fn foo(val: *const S) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print(
|
||||
"{d} {d}\n",
|
||||
.{ val.x, val.y },
|
||||
);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="100 200\n"
|
||||
|
||||
#update=change values
|
||||
|
|
@ -45,11 +47,12 @@ pub fn main() !void {
|
|||
try foo(&val);
|
||||
}
|
||||
fn foo(val: *const S) !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print(
|
||||
"{d} {d}\n",
|
||||
.{ val.x, val.y },
|
||||
);
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="1234 5678\n"
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
const std = @import("std");
|
||||
const message: []const u8 = @import("message.zon");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(message);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, message);
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#file=message.zon
|
||||
"Hello, World!\n"
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
|
@ -29,8 +30,9 @@ pub fn main() !void {
|
|||
const std = @import("std");
|
||||
const message: []const u8 = @import("message.zon");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("a hardcoded string\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "a hardcoded string\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=message.zon:1:1: error: unable to load 'message.zon': FileNotFound
|
||||
#expect_error=main.zig:2:37: note: file imported here
|
||||
|
||||
|
|
@ -44,6 +46,7 @@ pub fn main() !void {
|
|||
const std = @import("std");
|
||||
const message: []const u8 = @import("message.zon");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(message);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, message);
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="We're back, World!\n"
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@
|
|||
#update=initial version
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(@import("foo.zon").message);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @import("foo.zon").message);
|
||||
}
|
||||
#file=foo.zon
|
||||
.{
|
||||
|
|
|
|||
|
|
@ -8,17 +8,19 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
||||
#update=add compile log
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
@compileLog("this is a log");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:4:5: error: found compile log statement
|
||||
#expect_compile_log=@as(*const [13:0]u8, "this is a log")
|
||||
|
||||
|
|
@ -26,6 +28,7 @@ pub fn main() !void {
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
|
|
|||
|
|
@ -10,28 +10,31 @@ pub fn main() !void {
|
|||
}
|
||||
#file=foo.zig
|
||||
pub fn hello() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "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.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
#update=add new error
|
||||
#file=foo.zig
|
||||
const std = @import("std");
|
||||
pub fn hello() !void {
|
||||
try std.Io.File.stdout().writeAll(hello_str);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, hello_str);
|
||||
}
|
||||
#expect_error=foo.zig:3:39: error: use of undeclared identifier 'hello_str'
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=foo.zig:3:52: 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.File.stdout().writeAll(hello_str);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, hello_str);
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World! Again!\n"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ pub fn main() !void {
|
|||
try foo();
|
||||
}
|
||||
fn foo() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
||||
#update=make function inline
|
||||
|
|
@ -19,9 +20,10 @@ pub fn main() !void {
|
|||
try foo();
|
||||
}
|
||||
inline fn foo() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
||||
#update=change string
|
||||
|
|
@ -30,7 +32,8 @@ pub fn main() !void {
|
|||
try foo();
|
||||
}
|
||||
inline fn foo() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, `inline` World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, `inline` World!\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, `inline` World!\n"
|
||||
|
|
|
|||
|
|
@ -6,14 +6,16 @@
|
|||
#update=initial version
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("good morning\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "good morning\n");
|
||||
}
|
||||
#expect_stdout="good morning\n"
|
||||
#update=change the string
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll("おはようございます\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "おはようございます\n");
|
||||
}
|
||||
#expect_stdout="おはようございます\n"
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ pub fn main() !void {
|
|||
#file=foo.zig
|
||||
const std = @import("std");
|
||||
fn hello() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:3:12: error: 'hello' is not marked 'pub'
|
||||
#expect_error=foo.zig:2:1: note: declared here
|
||||
|
||||
|
|
@ -21,6 +22,7 @@ fn hello() !void {
|
|||
#file=foo.zig
|
||||
const std = @import("std");
|
||||
pub fn hello() !void {
|
||||
try std.Io.File.stdout().writeAll("Hello, World!\n");
|
||||
try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n");
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
|
|
|||
|
|
@ -8,20 +8,22 @@
|
|||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
const str = getStr();
|
||||
try std.Io.File.stdout().writeAll(str);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, str);
|
||||
}
|
||||
inline fn getStr() []const u8 {
|
||||
return "foo\n";
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="foo\n"
|
||||
#update=change the string
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
const str = getStr();
|
||||
try std.Io.File.stdout().writeAll(str);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, str);
|
||||
}
|
||||
inline fn getStr() []const u8 {
|
||||
return "bar\n";
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="bar\n"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{d} {d}\n", .{ foo(), bar() });
|
||||
}
|
||||
fn foo() u32 {
|
||||
|
|
@ -16,13 +16,14 @@ fn foo() u32 {
|
|||
fn bar() u32 {
|
||||
return 123;
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="7 123\n"
|
||||
|
||||
#update=add newline
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{d} {d}\n", .{ foo(), bar() });
|
||||
}
|
||||
|
||||
|
|
@ -32,4 +33,5 @@ fn foo() u32 {
|
|||
fn bar() u32 {
|
||||
return 123;
|
||||
}
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="8 123\n"
|
||||
|
|
|
|||
|
|
@ -7,15 +7,17 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
var some_enum: enum { first, second } = .first;
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeStreamingAll(std.Io.Threaded.global_single_threaded.ioBasic(), @tagName(some_enum));
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @tagName(some_enum));
|
||||
}
|
||||
#expect_stdout="first"
|
||||
#update=no change
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
var some_enum: enum { first, second } = .first;
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeStreamingAll(std.Io.Threaded.global_single_threaded.ioBasic(), @tagName(some_enum));
|
||||
try std.Io.File.stdout().writeStreamingAll(io, @tagName(some_enum));
|
||||
}
|
||||
#expect_stdout="first"
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ pub fn main() !void {
|
|||
fn foo(recurse: bool) !void {
|
||||
const stdout = std.Io.File.stdout();
|
||||
if (recurse) return foo(true);
|
||||
try stdout.writeAll("non-recursive path\n");
|
||||
try stdout.writeStreamingAll(io, "non-recursive path\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="non-recursive path\n"
|
||||
|
||||
#update=eliminate recursion and change argument
|
||||
|
|
@ -23,8 +24,9 @@ pub fn main() !void {
|
|||
}
|
||||
fn foo(recurse: bool) !void {
|
||||
const stdout = std.Io.File.stdout();
|
||||
if (recurse) return stdout.writeAll("x==1\n");
|
||||
try stdout.writeAll("non-recursive path\n");
|
||||
if (recurse) return stdout.writeStreamingAll(io, "x==1\n");
|
||||
try stdout.writeStreamingAll(io, "non-recursive path\n");
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="x==1\n"
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ const MyEnum = enum(u8) {
|
|||
bar = 2,
|
||||
};
|
||||
pub fn main() !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{}\n", .{@intFromEnum(MyEnum.foo)});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="1\n"
|
||||
#update=remove enum field
|
||||
#file=main.zig
|
||||
|
|
@ -22,9 +23,10 @@ const MyEnum = enum(u8) {
|
|||
bar = 2,
|
||||
};
|
||||
pub fn main() !void {
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});
|
||||
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
||||
try stdout_writer.interface.print("{}\n", .{@intFromEnum(MyEnum.foo)});
|
||||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -7,36 +7,40 @@
|
|||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(a);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, a);
|
||||
}
|
||||
const a = "Hello, World!\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hello, World!\n"
|
||||
|
||||
#update=introduce compile error
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(a);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, a);
|
||||
}
|
||||
const a = @compileError("bad a");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:5:11: error: bad a
|
||||
|
||||
#update=remove error reference
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(b);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, b);
|
||||
}
|
||||
const a = @compileError("bad a");
|
||||
const b = "Hi there!\n";
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Hi there!\n"
|
||||
|
||||
#update=introduce and remove reference to error
|
||||
#file=main.zig
|
||||
const std = @import("std");
|
||||
pub fn main() !void {
|
||||
try std.Io.File.stdout().writeAll(a);
|
||||
try std.Io.File.stdout().writeStreamingAll(io, a);
|
||||
}
|
||||
const a = "Back to a\n";
|
||||
const b = @compileError("bad b");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_stdout="Back to a\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue