m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-14 18:13:21 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-14 18:13:21 -0400
commita15a2986c95131a13d3707ae50f8a215dcaac564 (patch)
tree48e0bf9d95508ba9a94bfb2fd6f4bff51a89a25a /__tests__
parent9f4197c659207534401ee6a7299275bf4d109949 (diff)
Lex and parse addition
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/parser.test.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js
index 004e18b..b0dc28d 100644
--- a/__tests__/parser.test.js
+++ b/__tests__/parser.test.js
@@ -32,4 +32,28 @@ describe('parse', () => {
}
})
})
+
+ it('parses constant addition', () => {
+ expect(parse('1 + 2')).toEqual({
+ type: 'add',
+ left: { type: 'constant', value: 1 },
+ right: { type: 'constant', value: 2 }
+ })
+ })
+
+ it('parses dice addition', () => {
+ expect(parse('1d6 + 2d8')).toEqual({
+ type: 'add',
+ 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 }
+ }
+ })
+ })
})