From ba07c4d236d2a03f5f7647cf4e724f853703172f Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Wed, 19 Jul 2017 22:38:24 -0400 Subject: Create failing explode tests --- __tests__/dice.test.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to '__tests__') diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js index 527db81..1274b3d 100644 --- a/__tests__/dice.test.js +++ b/__tests__/dice.test.js @@ -1,4 +1,12 @@ -const { pool, constant, d, add, subtract, negative } = require('../src/dice.js') +const { + pool, + constant, + d, + add, + subtract, + negative, + explode +} = require('../src/dice.js') const defaultNumberRolls = 500 const defaultError = 0.2 @@ -332,3 +340,41 @@ describe('compound dice', () => { testDie(die, basicDieTestSpecs(2, 2)) }) }) + +describe('exploding dice', () => { + describe('6E1d6', () => { + const die = explode(constant(6), d(constant(1), constant(6))) + testDie(die, { + diceCount: 1, + average: { + average: 4.2 + }, + variance: { + variance: 10.64 + }, + bounds: { + low: 1, + expectLow: true, + high: Infinity + } + }) + }) + + describe('6E2d6', () => { + const die = explode(constant(6), d(constant(2), constant(6))) + testDie(die, { + diceCount: 2, + average: { + average: 2 * 4.2 + }, + variance: { + variance: 2 * 10.64 + }, + bounds: { + low: 2, + expectLow: true, + high: Infinity + } + }) + }) +}) -- cgit v1.2.3