forked from SimpleRegex/SRL-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions-test.js
More file actions
36 lines (28 loc) · 1 KB
/
exceptions-test.js
File metadata and controls
36 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict'
const assert = require('assert')
const SRL = require('../')
const BuilderException = require('../lib/Exceptions/Builder')
const ImplementationException = require('../lib/Exceptions/Implementation')
describe('Builder Exceptions', () => {
it('Raw method', () => {
const regex = new SRL('Literally "a"')
assert['throws'](() => {
regex.raw(')')
}, (error) => {
return error instanceof BuilderException &&
error.message === 'Adding raw would invalidate this regular expression. Reverted.' &&
regex.test('a')
})
})
})
describe('Implementation Exception', () => {
it('Lazy Method', () => {
const regex = new SRL('Literally "a"')
assert['throws'](() => {
regex.lazy()
}, (error) => {
return error instanceof ImplementationException &&
error.message === 'Cannot apply laziness at this point. Only applicable after quantifier.'
})
})
})