From 1cc6b80cfd4875f289837421cdbe81e3dfcf0ed1 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sat, 2 Sep 2017 00:47:46 -0400 Subject: Implement repeat --- __tests__/parser.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to '__tests__/parser.test.js') diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js index bef11c5..d696b3e 100644 --- a/__tests__/parser.test.js +++ b/__tests__/parser.test.js @@ -285,6 +285,22 @@ describe('parse', () => { }) }) + it('parses dice with repeat', () => { + expect(parse('1d6 x 1d4')).toEqual({ + type: 'repeat', + left: { + type: 'd', + left: { type: 'constant', value: 1 }, + 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({ -- cgit v1.2.3