m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-12 23:04:16 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-12 23:04:16 -0400
commit2571bdc80a25b0137194bab58029765abe8870b2 (patch)
tree6c8240f767e9828b9feb3000474ee110f4eb674c /__tests__
parentdd0b2d0fff6d9d8a8350091369a7cfdfacb19499 (diff)
Lex addition
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/lexer.test.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/__tests__/lexer.test.js b/__tests__/lexer.test.js
index 37158e6..e887e09 100644
--- a/__tests__/lexer.test.js
+++ b/__tests__/lexer.test.js
@@ -40,4 +40,28 @@ describe('lex', () => {
])
})
})
+
+ describe('lexes addition', () => {
+ it('1d6 + 1d4', () => {
+ expect(lex('1d6 + 1d4')).toEqual([
+ { type: 'number', value: 1 },
+ { type: 'd' },
+ { type: 'number', value: 6 },
+ { type: '+' },
+ { type: 'number', value: 1 },
+ { type: 'd' },
+ { type: 'number', value: 4 }
+ ])
+ })
+
+ it('2d17 + 4', () => {
+ expect(lex('2d17 + 4')).toEqual([
+ { type: 'number', value: 2 },
+ { type: 'd' },
+ { type: 'number', value: 17 },
+ { type: '+' },
+ { type: 'number', value: 4 }
+ ])
+ })
+ })
})