diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-10 14:46:19 -0400 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-10 15:18:45 -0400 |
commit | cbfed7099a748c586d984611e9b46ecc55ea3b68 (patch) | |
tree | cdf933f76b77748d46e0a200c7be3539cdb82d81 | |
parent | 02b9b21e5af96966c24daeb0c99287003ec110cb (diff) |
Expect extrema if there's a good chance of attaining them
-rw-r--r-- | __tests__/dice.test.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js index ea4d415..75fd06a 100644 --- a/__tests__/dice.test.js +++ b/__tests__/dice.test.js @@ -60,6 +60,7 @@ expect.extend({ }) const plus = (a, b) => a + b +const times = (a, b) => a * b const rollForTest = (die, numberRolls) => { let pools = [] @@ -130,7 +131,7 @@ const basicDieTestSpecs = (number, sides) => { bounds: { low: number, high: number * sides, - expectExtrema: true + expectExtrema: number * sides < 50 } } } @@ -156,6 +157,8 @@ const combinedDiceTestSpecs = (dieSpecs) => { bounds: { low: combineSpecField(spec => (spec.bounds.low)), high: combineSpecField(spec => (spec.bounds.high)), + expectExtrema: dieSpecs.map(spec => (Math.pow(spec.sides, spec.number))) + .reduce(times) < 50 } } } |