octo-deno/tests/random/mersennetwister.js
Jesse Schwartzentruber b3c7ecbe2f Switch from qunit (node) and slimerjs to karma which supports running
qunit tests in firefox and chrome.

Maintaining code to work in node for testing only will be error-prone.
2017-04-10 13:49:32 -04:00

24 lines
594 B
JavaScript

/* XXX: translate some of the dieharder tests here? */
QUnit.test("MersenneTwister test distribution", function(assert) {
let mt = new MersenneTwister();
mt.seed(new Date().getTime());
for (let i = 0; i < 100; ++i) {
let a = [], again = false;
for (let j = 0; j < 10; ++j) {
a[j] = mt.int32();
}
a.sort();
for (let j = 0; j < (a.length - 1); ++j) {
if (a[j] === a[j+1]) {
again = true;
}
}
if (!again) {
assert.ok(true, "no dupes in 10 entries");
return;
}
}
assert.ok(false, "could not get unique entries");
});