On Tuesday, 1 September 2015 at 18:25:06 UTC, H. S. Teoh wrote:
On Tue, Sep 01, 2015 at 06:14:05PM +0000, deadalnix via
Digitalmars-d wrote:
A ton of code is not unitestable. GUI as a starter. Random
number generator. Very rare events handling outside the
control of the program. Concurent code. Etc...
That would explain why GUI apps tend to be buggy and
unreliable, and RNGs tend to have unintended biases.
No, actually, GUIs should be written to be testable (e.g.,
input should be abstracted via dependency injection so that GUI
interactions are scriptable, at least inside a unittest, with
expected final states).
RNGs can be unittested for uniform distribution within certain
bounds. Unittest does not necessarily mean checking for
equality (even though that's the most common usage).
Some of this depends on whether you're talking about
pseudo-random or 'true' random number generators. With the
former you can e.g. verify that particular seeds produce expected
sequences, etc., so you can at least test equivalence of
implementations.
Testing (true or pseudo) RNGs for desired statistical properties
(not just distribution but also periodicity, etc.) is readily
possible, it's just rather more costly than is desirable for
unittests.