m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__/lexer.test.js
diff options
context:
space:
mode:
Diffstat (limited to '__tests__/lexer.test.js')
-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 6434e17..e9115a1 100644
--- a/__tests__/lexer.test.js
+++ b/__tests__/lexer.test.js
@@ -64,4 +64,28 @@ describe('lex', () => {
])
})
})
+
+ describe('lexes subtraction', () => {
+ it('1d6 - 1d4', () => {
+ expect(lex('1d6 - 1d4')).toEqual([
+ { type: 'constant', value: 1 },
+ { type: 'd' },
+ { type: 'constant', value: 6 },
+ { type: '-' },
+ { type: 'constant', value: 1 },
+ { type: 'd' },
+ { type: 'constant', value: 4 }
+ ])
+ })
+
+ it('2d17 - 4', () => {
+ expect(lex('2d17 - 4')).toEqual([
+ { type: 'constant', value: 2 },
+ { type: 'd' },
+ { type: 'constant', value: 17 },
+ { type: '-' },
+ { type: 'constant', value: 4 }
+ ])
+ })
+ })
})