en.javascript.info/1-js/06-advanced-functions/13-generators/01-pseudo-random-generator/_js.view/test.js
2019-03-02 23:36:53 +03:00

21 lines
612 B
JavaScript

describe("pseudoRandom", function() {
it("follows the formula", function() {
let generator = pseudoRandom(1);
assert.equal(generator.next().value, 16807);
assert.equal(generator.next().value, 282475249);
assert.equal(generator.next().value, 1622650073);
});
it("returns same value for the same seed", function() {
let generator1 = pseudoRandom(123);
let generator2 = pseudoRandom(123);
assert.deepEqual(generator1.next(), generator2.next());
assert.deepEqual(generator1.next(), generator2.next());
assert.deepEqual(generator1.next(), generator2.next());
});
});