-
Notifications
You must be signed in to change notification settings - Fork 509
/
Copy pathre.js
26 lines (23 loc) · 912 Bytes
/
re.js
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
const { test } = require('tap')
const { src, re, safeRe, safeSrc } = require('../../internal/re')
const semver = require('../../')
test('Semver itself has a list of src, re, and tokens', (t) => {
t.match(Object.assign({}, semver), {
re: Array,
src: Array,
tokens: Object,
})
re.forEach(r => t.match(r, RegExp, 'regexps are regexps'))
safeRe.forEach(r => t.match(r, RegExp, 'safe regexps are regexps'))
src.forEach(s => t.match(s, String, 'src are strings'))
safeSrc.forEach(s => t.match(s, String, 'safe srcare strings'))
t.ok(Object.keys(semver.tokens).length, 'there are tokens')
for (const i in semver.tokens) {
t.match(semver.tokens[i], Number, 'tokens are numbers')
}
safeRe.forEach(r => {
t.notMatch(r.source, '\\s+', 'safe regex do not contain greedy whitespace')
t.notMatch(r.source, '\\s*', 'safe regex do not contain greedy whitespace')
})
t.end()
})