From fe1bb829ba1feeb4d8f384afe0ed62669d82407f Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Wed, 23 Aug 2017 21:30:01 -0400 Subject: Lex and parse threshold --- __tests__/lexer.test.js | 12 ++++++++++++ __tests__/parser.test.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) (limited to '__tests__') diff --git a/__tests__/lexer.test.js b/__tests__/lexer.test.js index 5ae84cc..21ae3b0 100644 --- a/__tests__/lexer.test.js +++ b/__tests__/lexer.test.js @@ -194,4 +194,16 @@ describe('lex', () => { ]) }) }) + + describe('threshold', () => { + test('8T3d10', () => { + expect(lex('8T3d10')).toEqual([ + { type: 'constant', value: 8 }, + { type: 'T' }, + { type: 'constant', value: 3 }, + { type: 'd' }, + { type: 'constant', value: 10 } + ]) + }) + }) }) diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js index 6bf5958..70ad98d 100644 --- a/__tests__/parser.test.js +++ b/__tests__/parser.test.js @@ -211,6 +211,18 @@ describe('parse', () => { }) }) + it('parases dice with threshold', () => { + expect(parse('7T4d8')).toEqual({ + type: 'T', + left: { type: 'constant', value: 7 }, + right: { + type: 'd', + left: { type: 'constant', value: 4 }, + right: { type: 'constant', value: 8 } + } + }) + }) + describe('parsing parentheses', () => { test('(1d6)d6', () => { expect(parse('(1d6)d6')).toEqual({ -- cgit v1.2.3