diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-15 22:48:10 -0400 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-15 23:09:22 -0400 |
commit | e0ab43bcdc050ca3cac2adea927817d99700737e (patch) | |
tree | e11746830954eba9ec7a030f5588325c53a258ef /__tests__/lexer.test.js | |
parent | 522654d5bf68636a39477f67fa4fd04961f5a6d0 (diff) |
Throw Error on syntax errors
Diffstat (limited to '__tests__/lexer.test.js')
-rw-r--r-- | __tests__/lexer.test.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/__tests__/lexer.test.js b/__tests__/lexer.test.js index 38c880e..b9260b8 100644 --- a/__tests__/lexer.test.js +++ b/__tests__/lexer.test.js @@ -5,8 +5,16 @@ describe('lex', () => { expect(lex('')).toEqual([]) }) - it('signals an error on unexpected input', () => { - expect(lex('q')).toBe('error') + it('throws on unexpected input', () => { + expect(() => { lex('q') }).toThrow(/Syntax error/) + }) + + it('throws on unexpected input at the end', () => { + expect(() => { lex('1d6 `') }).toThrow(/Syntax error/) + }) + + it('throws on unexpected input in the middle', () => { + expect(() => { lex('2d3 + b 3d4') }).toThrow(/Syntax error/) }) describe('ignores whitespace', () => { |