Closed LarryBattle closed 9 years ago
I'll hopefully be working on this in the next while
so many other tests are failing. I thought it was just that one, it seemed to have been giving us the most problems but apparently that's not the case. I'm just going to skew the error bounds on the tests so that it has a better chance of passing. it may be hacky but random numbers are wonky so whatever.
I tried the latest code from master with your changes but it didn't really help to lower the error rate.
I think this is the real problem. In order for the random functions to be testable, a predetermined seed value for the pseudo random number generator must be used. Currently, there's no way to achieve this.
Here's one possible solution.
In the random
module, add a setter for the random number generator instead of hard coding to Math.random()
.
I see two benefits here.
1) Users could replace Math.random()
with a cryptographic-grade random number generator.
2) Test cases would become predictable.
During testing, we could use an alternative to the plain old Math.random()
.
Possible options:
function(){ return CONSTANT }
I'll try to submit a pull request soon.
The test cases for
random.distribution.*
fail 15% of the time. This is causing working builds to randomly fail in Travis CI. Thus a rewrite of the test cases is needed. Unfortunately I need to read up on this subject matter before I can proceed with a rewrite.Example of a failed Travis CI build
Error Message:
Source: https://travis-ci.org/sjkaliski/numbers.js/jobs/35846620