m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__/parser.test.js
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-09-11 15:47:50 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-09-11 15:47:50 -0400
commit9368b1c33db290d7c80c93db5c867cdb7fcaf14d (patch)
treec6170c157985624b373a13bb540bd4070321c18c /__tests__/parser.test.js
parentda6582f328c17e1842a4632d88e06d851e7c4b5f (diff)
Implement collecting
Diffstat (limited to '__tests__/parser.test.js')
-rw-r--r--__tests__/parser.test.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js
index 3c9f6ec..cb89ad5 100644
--- a/__tests__/parser.test.js
+++ b/__tests__/parser.test.js
@@ -325,6 +325,25 @@ describe('parse', () => {
})
})
+ it('parses dice with collecting', () => {
+ expect(parse('[2d6] x 1d4')).toEqual({
+ type: 'repeat',
+ left: {
+ type: 'collect',
+ value: {
+ type: 'd',
+ left: { type: 'constant', value: 2 },
+ right: { type: 'constant', value: 6 }
+ }
+ },
+ right: {
+ type: 'd',
+ left: { type: 'constant', value: 1 },
+ right: { type: 'constant', value: 4 }
+ }
+ })
+ })
+
describe('parsing parentheses', () => {
test('(1d6)d6', () => {
expect(parse('(1d6)d6')).toEqual({