octo-deno/tests/random/mersennetwister.js

24 lines
594 B
JavaScript
Raw Normal View History

2017-04-07 10:56:18 +00:00
/* XXX: translate some of the dieharder tests here? */
QUnit.test("MersenneTwister test distribution", function(assert) {
let mt = new MersenneTwister();
2017-04-07 10:56:18 +00:00
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");
});