| 1 | #exe { |
| 2 | -Mroot=main.zig |
| 3 | #} |
| 4 | |
| 5 | #write main.zig { |
| 6 | const std = @import("std"); |
| 7 | const string = @embedFile("string.txt"); |
| 8 | pub fn main() !void { |
| 9 | try std.Io.File.stdout().writeStreamingAll(io, string); |
| 10 | } |
| 11 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 12 | #} |
| 13 | #write string.txt { |
| 14 | Hello, World! |
| 15 | #} |
| 16 | #update |
| 17 | #check stdout { |
| 18 | Hello, World! |
| 19 | #} |
| 20 | |
| 21 | #write string.txt { |
| 22 | Hello again, World! |
| 23 | #} |
| 24 | #update "change file contents" |
| 25 | #check stdout { |
| 26 | Hello again, World! |
| 27 | #} |
| 28 | |
| 29 | #delete string.txt |
| 30 | #update "delete file" |
| 31 | #check errors { |
| 32 | main.zig:2:27: error: failed opening "string.txt": FileNotFound |
| 33 | #} |
| 34 | |
| 35 | #write main.zig { |
| 36 | const std = @import("std"); |
| 37 | const string = @embedFile("string.txt"); |
| 38 | pub fn main() !void { |
| 39 | try std.Io.File.stdout().writeStreamingAll(io, "a hardcoded string\n"); |
| 40 | } |
| 41 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 42 | #} |
| 43 | #update "remove reference to file" |
| 44 | #check stdout { |
| 45 | a hardcoded string |
| 46 | #} |
| 47 | |
| 48 | #write main.zig { |
| 49 | const std = @import("std"); |
| 50 | const string = @embedFile("string.txt"); |
| 51 | pub fn main() !void { |
| 52 | try std.Io.File.stdout().writeStreamingAll(io, string); |
| 53 | } |
| 54 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 55 | #} |
| 56 | #update "re-introduce reference to file" |
| 57 | #check errors { |
| 58 | main.zig:2:27: error: failed opening "string.txt": FileNotFound |
| 59 | #} |
| 60 | |
| 61 | #write string.txt { |
| 62 | We're back, World! |
| 63 | #} |
| 64 | #update "recreate file" |
| 65 | #check stdout { |
| 66 | We're back, World! |
| 67 | #} |