From 3a99beea32cda8850022458f39ad640966d1477d Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Wed, 23 Aug 2017 20:47:54 -0400 Subject: Lex and parse again --- __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 1e80c25..5ae84cc 100644 --- a/__tests__/lexer.test.js +++ b/__tests__/lexer.test.js @@ -182,4 +182,16 @@ describe('lex', () => { ]) }) }) + + describe('again', () => { + test('6A3d6', () => { + expect(lex('6A3d6')).toEqual([ + { type: 'constant', value: 6 }, + { type: 'A' }, + { type: 'constant', value: 3 }, + { type: 'd' }, + { type: 'constant', value: 6 } + ]) + }) + }) }) diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js index 25edbfc..6bf5958 100644 --- a/__tests__/parser.test.js +++ b/__tests__/parser.test.js @@ -199,6 +199,18 @@ describe('parse', () => { }) }) + it('parases dice with again', () => { + expect(parse('10A3d10')).toEqual({ + type: 'A', + left: { type: 'constant', value: 10 }, + right: { + type: 'd', + left: { type: 'constant', value: 3 }, + right: { type: 'constant', value: 10 } + } + }) + }) + describe('parsing parentheses', () => { test('(1d6)d6', () => { expect(parse('(1d6)d6')).toEqual({ -- cgit v1.2.3