m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-15 21:53:00 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-15 21:58:52 -0400
commit522654d5bf68636a39477f67fa4fd04961f5a6d0 (patch)
tree2ab59da9df23d3b631323ee250a1a2daad70d3a3 /__tests__
parent5597920f2561867db82cbd7dc5d81c34e6313364 (diff)
Test negative dice
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/dice.test.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 9f3106e..527db81 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -1,4 +1,4 @@
-const { pool, constant, d, add, subtract } = require('../src/dice.js')
+const { pool, constant, d, add, subtract, negative } = require('../src/dice.js')
const defaultNumberRolls = 500
const defaultError = 0.2
@@ -187,10 +187,14 @@ const combinedDiceTestSpecs = (dieSpecs) => {
}
}
-const describeBasicDie = (number, sides, numberRolls = defaultNumberRolls) => {
+const describeBasicDie = (number, sides, numberRolls = defaultNumberRolls,
+ neg = false) => {
describe(`${number}d${sides}`, () => {
- const die = d(constant(number), constant(sides))
- testDie(die, basicDieTestSpecs(number, sides), numberRolls)
+ let die = d(constant(number), constant(sides))
+ if (neg) {
+ die = negative(die)
+ }
+ testDie(die, basicDieTestSpecs(number, sides, neg), numberRolls)
})
}
@@ -277,6 +281,12 @@ describe('add', () => {
])
})
+describe('negative', () => {
+ describeBasicDie(1, 6, defaultNumberRolls, true)
+ describeBasicDie(0, 6, defaultNumberRolls, true)
+ describeBasicDie(2, 8, defaultNumberRolls, true)
+})
+
describe('subtract', () => {
describeCompoundDice([
{ number: 1, sides: 6 },