| 1 | #update=initial version |
| 2 | #file=main.zig |
| 3 | const std = @import("std"); |
| 4 | const string = @embedFile("string.txt"); |
| 5 | pub fn main() !void { |
| 6 | try std.Io.File.stdout().writeStreamingAll(io, string); |
| 7 | } |
| 8 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 9 | #file=string.txt |
| 10 | Hello, World! |
| 11 | #expect_stdout="Hello, World!\n" |
| 12 | |
| 13 | #update=change file contents |
| 14 | #file=string.txt |
| 15 | Hello again, World! |
| 16 | #expect_stdout="Hello again, World!\n" |
| 17 | |
| 18 | #update=delete file |
| 19 | #rm_file=string.txt |
| 20 | #expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound |
| 21 | |
| 22 | #update=remove reference to file |
| 23 | #file=main.zig |
| 24 | const std = @import("std"); |
| 25 | const string = @embedFile("string.txt"); |
| 26 | pub fn main() !void { |
| 27 | try std.Io.File.stdout().writeStreamingAll(io, "a hardcoded string\n"); |
| 28 | } |
| 29 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 30 | #expect_stdout="a hardcoded string\n" |
| 31 | |
| 32 | #update=re-introduce reference to file |
| 33 | #file=main.zig |
| 34 | const std = @import("std"); |
| 35 | const string = @embedFile("string.txt"); |
| 36 | pub fn main() !void { |
| 37 | try std.Io.File.stdout().writeStreamingAll(io, string); |
| 38 | } |
| 39 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 40 | #expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound |
| 41 | |
| 42 | #update=recreate file |
| 43 | #file=string.txt |
| 44 | We're back, World! |
| 45 | #expect_stdout="We're back, World!\n" |