From cbfed7099a748c586d984611e9b46ecc55ea3b68 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 10 Jul 2017 14:46:19 -0400 Subject: Expect extrema if there's a good chance of attaining them --- __tests__/dice.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 } } } -- cgit v1.2.3