m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-14 23:35:23 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-14 23:35:23 -0400
commitde517d06737f77a0cfc818c159b388b4e0c4d6b1 (patch)
treeeb32f4a2cf994ed2f5401bb1e194d1080938d19a /__tests__
parentc5b9b7d03a37b807b212c29a9bdf7afc837c5423 (diff)
Lex and parse negatives
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/parser.test.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js
index a741007..74ca442 100644
--- a/__tests__/parser.test.js
+++ b/__tests__/parser.test.js
@@ -73,6 +73,24 @@ describe('parse', () => {
})
})
+ it('parses negatives', () => {
+ expect(parse('-1 + (-(2d6))')).toEqual({
+ type: 'add',
+ left: {
+ type: 'negative',
+ value: { type: 'constant', value: 1 }
+ },
+ right: {
+ type: 'negative',
+ value: {
+ type: 'd',
+ left: { type: 'constant', value: 2 },
+ right: { type: 'constant', value: 6 }
+ }
+ }
+ })
+ })
+
describe('parsing parentheses', () => {
test('(1d6)d6', () => {
expect(parse('(1d6)d6')).toEqual({