| 1 | #exe { |
| 2 | -Mroot=main.zig |
| 3 | #} |
| 4 | |
| 5 | #write main.zig { |
| 6 | const std = @import("std"); |
| 7 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 8 | fn Printer(message: []const u8) type { |
| 9 | return struct { |
| 10 | fn print() !void { |
| 11 | try std.Io.File.stdout().writeStreamingAll(io, message); |
| 12 | } |
| 13 | }; |
| 14 | } |
| 15 | pub fn main() !void { |
| 16 | try Printer("foo\n").print(); |
| 17 | try Printer("bar\n").print(); |
| 18 | } |
| 19 | #} |
| 20 | #update |
| 21 | #check stdout { |
| 22 | foo |
| 23 | bar |
| 24 | #} |
| 25 | |
| 26 | #write main.zig { |
| 27 | const std = @import("std"); |
| 28 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 29 | |
| 30 | fn Printer(message: []const u8) type { |
| 31 | return struct { |
| 32 | fn print() !void { |
| 33 | try std.Io.File.stdout().writeStreamingAll(io, message); |
| 34 | } |
| 35 | }; |
| 36 | } |
| 37 | pub fn main() !void { |
| 38 | try Printer("foo\n").print(); |
| 39 | try Printer("bar\n").print(); |
| 40 | } |
| 41 | #} |
| 42 | #update "change line number" |
| 43 | #check stdout { |
| 44 | foo |
| 45 | bar |
| 46 | #} |