A short mixin can be a wonderful thing. Like for unittests:
string test(string name)()
{
return `
Stdout("` ~ name ~ `");
scope (failure) Stdout("failed").newline;
scope (success) Stdout("passed").newline;`
}
unittest
{
mixin(test!("test naming test"));
}
But mixins should be passive, delegating to concrete methods and classes whenever possible. Line numbers are that important.
No comments:
Post a Comment