diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-19 22:38:24 -0400 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-19 23:14:36 -0400 |
commit | ba07c4d236d2a03f5f7647cf4e724f853703172f (patch) | |
tree | 8d1c4baa59a0ee22e8448157eb3b8e43ed361225 /__tests__ | |
parent | 3d394316505d7c64975e1d5a9d1e04b8da1903c3 (diff) |
Create failing explode tests
Diffstat (limited to '__tests__')
-rw-r--r-- | __tests__/dice.test.js | 48 |
1 files changed, 47 insertions, 1 deletions
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 + } + }) + }) +}) |