Skip to content

Instantly share code, notes, and snippets.

@mohayonao
Last active December 29, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohayonao/7699209 to your computer and use it in GitHub Desktop.
Save mohayonao/7699209 to your computer and use it in GitHub Desktop.
random generator for tests
var Random = function() {
var s1 = 1243598713, s2 = 3093459404, s3 = 1821928721;
return function() {
s1 = ((s1 & 4294967294) << 12) ^ (((s1 << 13) ^ s1) >>> 19);
s2 = ((s2 & 4294967288) << 4) ^ (((s2 << 2) ^ s2) >>> 25);
s3 = ((s3 & 4294967280) << 17) ^ (((s3 << 3) ^ s3) >>> 11);
return ((s1 ^ s2 ^ s3) >>> 0) / 4294967296;
};
};
describe("random", function() {
var _random = Math.random;
beforeEach(function() {
Math.random = new Random();
});
afterEach(function() {
Math.random = _random;
});
it("coin", function() {
var coin = Math.random();
assert.ok(coin > 0.5);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment