On 05.11.2013 17:40, bearophile wrote:
Meta:

I've seen Jacob Carlborg suggest that unittests should be put in a
separate module before, maybe this is an argument for that, even in
smaller projects.

Putting the unittests very close to their functions/methods is very
good, for various reasons. I even sometimes write functions like this:

void foo() {
     ...
} unittest {
     ...
}

I routinely do both in my code - test functionality in the same module, and the interface in a separate module.

Also, I love writing unittests the way you mention here - I've gotten used to thinking something's wrong if there's not a unittest block immediately following a function. It looks nice, and meshes nicely with DBC:

auto foo(Args args)
in {
} out {
} body {
} unittest {
}

--
  Simen

Reply via email to