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