import lu.deltastrings : formatDeltaInto;
import lu.string : tabs;
import std.array : Appender;
import std.format : formattedWrite;
Appender!(char[]) sink;
sink.reserve(1024);
IRCClient client;
IRCServer server;
auto parser = IRCParser(client, server);
immutable event = parser.toIRCEvent(":zorael!~NaN@2001:41d0:2:80b4:: PRIVMSG #flerrp :kameloso: 8ball");
// copy/paste the above
sink.put("{\n");
sink.formattedWrite("%simmutable event = parser.toIRCEvent(\"%s\");\n", 1.tabs, event.raw);
sink.formattedWrite("%swith (event)\n", 1.tabs);
sink.formattedWrite("%s{\n", 1.tabs);
sink.formatDeltaInto!(Yes.asserts)(IRCEvent.init, event, 2);
sink.formattedWrite("%s}\n", 1.tabs);
sink.put("}");
assert(sink.data ==
`{
immutable event = parser.toIRCEvent(":zorael!~NaN@2001:41d0:2:80b4:: PRIVMSG #flerrp :kameloso: 8ball");
with (event)
{
assert((type == IRCEvent.Type.CHAN), Enum!(IRCEvent.Type).toString(type));
assert((sender.nickname == "zorael"), sender.nickname);
assert((sender.ident == "~NaN"), sender.ident);
assert((sender.address == "2001:41d0:2:80b4::"), sender.address);
assert((channel == "#flerrp"), channel);
assert((content == "kameloso: 8ball"), content);
}
}`, '\n' ~ sink.data);
Constructs assert statement blocks for each changed field of an IRCEvent.