From 1426322eb4898cd49310c1dc30cdfc8ad8e73402 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Tue, 22 Aug 2017 18:01:48 -0400 Subject: Parse negative bonuses --- __tests__/parser.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to '__tests__/parser.test.js') diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js index 873972b..54e1da7 100644 --- a/__tests__/parser.test.js +++ b/__tests__/parser.test.js @@ -163,6 +163,18 @@ describe('parse', () => { }) }) + it('parses negative bonuses', () => { + expect(parse('3d4-1')).toEqual({ + type: 'bonusSubtract', + left: { + type: 'd', + left: { type: 'constant', value: 3 }, + right: { type: 'constant', value: 4 } + }, + right: { type: 'constant', value: 1 } + }) + }) + describe('parsing parentheses', () => { test('(1d6)d6', () => { expect(parse('(1d6)d6')).toEqual({ -- cgit v1.2.3