In Taming Immutable Data Types in D with librebindable by Mathis Beer, in the Q&A, it was pointed out that it’s quite common to forget testing template code against types that do exotic (yet valid) things, e.g. @disable this()
, define/@disable
the copy constructor, contain qualified members, be immutable, etc.
One way to mitigate this would be a Phobos module (name it std.testing
or something) that – possibly among other things – defines aptly named types that are irregular for the sole purpose of being used as examples, together with various AliasSeqs that group types that belong together somehow. Then, one could do:
unittest
{
import std.testing;
static foreach (T; IrregularStructs)
{
T obj; // can default construct? T = NoDefaultCtor fails.
auto obj2 = obj; // can copy? T = NoCopyCtor fails.
// etc.?
}
}
Anyone can find some irregular types and test against them, but looking into every corner requires extensive knowledge about the language’s niches.