unittesting generic functions

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 14 13:42:59 PDT 2014


On Thu, Aug 14, 2014 at 08:38:31PM +0000, bearophile via Digitalmars-d wrote:
[...]
> H. S. Teoh:
> 
> >When should such unittests be run, and how should the following code
> >behave?
> 
> Is just after the post-condition of the enclosing function a good
> moment to run them?
[...]

So you're suggesting that these unittests should run at *every single
function call*? That sounds like total overkill to me.

Furthermore, if the unittest fails, what should the runtime do, now that
the program is actually already running? Aborting seems to be the most
reasonable answer, in which case the question is, why not just write
asserts in the outer function instead?


T

-- 
Skill without imagination is craftsmanship and gives us many useful objects such as wickerwork picnic baskets.  Imagination without skill gives us modern art. -- Tom Stoppard


More information about the Digitalmars-d mailing list