From eb6b9723b4364bd42820c9c5032458c3ec378077 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Mar 2019 05:07:02 +0100 Subject: [PATCH] (prng) test coverage --- prng.js | 10 +--------- prng.test.js | 5 ++++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/prng.js b/prng.js index 4b0f8ca..1d1651a 100644 --- a/prng.js +++ b/prng.js @@ -30,7 +30,7 @@ export const DefaultPRNG = Xoroshiro128plus * @param {number} seed A positive 32bit integer. Do not use negative numbers. * @return {PRNG} */ -export const create = seed => new DefaultPRNG(Math.floor(seed < 1 ? seed * binary.BITS32 : seed)) +export const create = seed => new DefaultPRNG(seed) /** * Generates a single random bool. @@ -82,14 +82,6 @@ export const int31 = (gen, min, max) => { return math.floor((gen.next() * (_max + 1 - _min)) + _min) } -/** - * Generates a random real on [0, 1) with 32 bit resolution. - * - * @param {PRNG} gen A random number generator. - * @return {Number} A random real number on [0, 1). - */ -export const real32 = gen => gen.next() - /** * Generates a random real on [0, 1) with 53 bit resolution. * diff --git a/prng.test.js b/prng.test.js index e5e6bb1..022852c 100644 --- a/prng.test.js +++ b/prng.test.js @@ -106,7 +106,7 @@ const runGenTest = (tc, gen) => { t.group('uint53 - generates integer exceeding 32 bits', () => { let largest = 0 - let smallest = 0 + let smallest = 10000 let i let newNum for (i = 0; i < genTestData; i++) { @@ -114,6 +114,7 @@ const runGenTest = (tc, gen) => { if (newNum > largest) { largest = newNum } + /* istanbul ignore if */ if (newNum < smallest) { smallest = newNum } @@ -175,6 +176,7 @@ export const testGeneratorXoroshiro128plus = tc => runGenTest(tc, new Xoroshiro1 export const testGeneratorXorshift32 = tc => runGenTest(tc, new Xorshift32(tc.seed)) export const testGeneratorMt19937 = tc => runGenTest(tc, new Mt19937(tc.seed)) +/* istanbul ignore next */ /** * @param {prng.PRNG} gen * @param {t.TestCase} tc @@ -195,6 +197,7 @@ const printDistribution = (gen, tc) => { t.printCanvas(canvas, DIAMETER) } +/* istanbul ignore next */ export const testNumberDistributions = tc => { t.skip(!isBrowser) t.group('Xoroshiro128plus', () => printDistribution(new Xoroshiro128plus(tc.seed), tc))