How to use the pure-rand.mersenne function in pure-rand

To help you get started, we’ve selected a few pure-rand examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dubzzz / fast-check / test / e2e / ReplayCommands.spec.ts View on Github external
it('Should be able to resume a stopped run by specifying replayPath in fc.commands', () => {
    const mrng = new fc.Random(prand.mersenne(seed));
    const out = fc.check(buildProp(undefined, mrng), { seed: seed });
    expect(out.failed).toBe(true);

    const path = out.counterexamplePath!;
    const replayPath = /\/\*replayPath=['"](.*)['"]\*\//.exec(out.counterexample![0].toString())![1];

    const outReplayed = fc.check(buildProp(replayPath), { seed, path });
    expect(outReplayed.counterexamplePath).toContain(out.counterexamplePath);
    expect(outReplayed.counterexamplePath!.startsWith(out.counterexamplePath!)).toBe(true);
  });
});
github dubzzz / fast-check / src / check / runner / configuration / QualifiedParameters.ts View on Github external
private static readRandomType = (p: Parameters): ((seed: number) => RandomGenerator) => {
    if (p.randomType == null) return prand.xorshift128plus;
    if (typeof p.randomType === 'string') {
      switch (p.randomType) {
        case 'mersenne':
          return prand.mersenne;
        case 'congruential':
          return prand.congruential;
        case 'congruential32':
          return prand.congruential32;
        case 'xorshift128plus':
          return prand.xorshift128plus;
        default:
          throw new Error(`Invalid random specified: '${p.randomType}'`);
      }
    }
    return p.randomType;
  };
  private static readNumRuns = (p: Parameters): number => {

pure-rand

Pure random number generator written in TypeScript

MIT
Latest version published 9 months ago

Package Health Score

79 / 100
Full package analysis