m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/lexer.test.js12
-rw-r--r--__tests__/parser.test.js12
2 files changed, 24 insertions, 0 deletions
diff --git a/__tests__/lexer.test.js b/__tests__/lexer.test.js
index b9260b8..3003fb9 100644
--- a/__tests__/lexer.test.js
+++ b/__tests__/lexer.test.js
@@ -124,4 +124,16 @@ describe('lex', () => {
])
})
})
+
+ describe('exploding dice', () => {
+ test('1E1d6', () => {
+ expect(lex('1E1d6')).toEqual([
+ { type: 'constant', value: 1 },
+ { type: 'E' },
+ { type: 'constant', value: 1 },
+ { type: 'd' },
+ { type: 'constant', value: 6 }
+ ])
+ })
+ })
})
diff --git a/__tests__/parser.test.js b/__tests__/parser.test.js
index 47944d2..26febef 100644
--- a/__tests__/parser.test.js
+++ b/__tests__/parser.test.js
@@ -115,6 +115,18 @@ describe('parse', () => {
})
})
+ it('parses exploding dice', () => {
+ expect(parse('1E1d6')).toEqual({
+ type: 'E',
+ left: { type: 'constant', value: 1 },
+ right: {
+ type: 'd',
+ left: { type: 'constant', value: 1 },
+ right: { type: 'constant', value: 6 }
+ }
+ })
+ })
+
describe('parsing parentheses', () => {
test('(1d6)d6', () => {
expect(parse('(1d6)d6')).toEqual({