From d3132a5463908bcabd0578ad48a457b2bec30a9a Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Fri, 14 Jul 2017 18:14:14 -0400 Subject: Lex and parse subtraction --- __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 b0dc28d..6fe296c 100644 --- a/__tests__/parser.test.js +++ b/__tests__/parser.test.js @@ -56,4 +56,20 @@ describe('parse', () => { } }) }) + + it('parses dice subtraction', () => { + expect(parse('1d6 - 2d8')).toEqual({ + type: 'subtract', + left: { + type: 'd', + left: { type: 'constant', value: 1 }, + right: { type: 'constant', value: 6 } + }, + right: { + type: 'd', + left: { type: 'constant', value: 2 }, + right: { type: 'constant', value: 8 } + } + }) + }) }) -- cgit v1.2.3