-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
comparison.makeRe.js
93 lines (79 loc) · 3.02 KB
/
comparison.makeRe.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'use strict';
var isTravis = process.env.CI || process.env.TRAVIS;
var isWindows = require('is-windows');
var assert = require('assert');
var bash = require('bash-match');
var mm = require('minimatch');
var nm = require('./support/matcher');
var fixtures = require('./_fixtures');
var patterns = require('./_patterns');
describe('.makeRe', function() {
if (isWindows() || isTravis) {
console.log('these tests use bash to test for bash parity. since bash does not work on most versions of windows, these tests are skipped on windows');
return;
}
patterns.forEach(function(pattern) {
// if (pattern !== 'a/b/c/**/*.js') return;
fixtures.forEach(function(fixture) {
// if (fixture !== 'a/b/c/z.js') return;
it('should match ' + fixture + ' with ' + pattern, function() {
var mmRes = mm.makeRe(pattern).test(fixture);
var nmRes = nm.makeRe(pattern).test(fixture);
var actual = nmRes === mmRes;
// minimatch is wrong on these
if (actual === false) {
// tie-breaker
if (nmRes === mm(fixture, pattern) || /^\?/.test(pattern)) {
actual = true;
} else if (!isWindows() && !isTravis) {
actual = nmRes === nm.bash.isMatch(fixture, pattern);
} else {
this.skip();
return;
}
}
assert(actual, fixture + ' ' + pattern);
});
it('should match ' + fixture + ' with ' + pattern + ' and {dot: true}', function() {
var mmRes = mm.makeRe(pattern, {dot: true}).test(fixture);
var nmRes = nm.makeRe(pattern, {dot: true}).test(fixture);
var actual = nmRes === mmRes;
// minimatch is wrong on these
if (actual === false) {
// tie-breaker
if (nmRes === mm(fixture, pattern, {dot: true})) {
actual = true;
} else if (/^\?/.test(pattern) || /^\.\//.test(fixture)) {
actual = true;
} else if (!isWindows() && !isTravis) {
actual = nmRes === nm.bash.isMatch(fixture, pattern, {dot: true});
} else {
this.skip();
return;
}
}
assert(actual, fixture + ' ' + pattern);
});
it('should match ' + fixture + ' with ' + pattern + ' and {nonegate: true}', function() {
var mmRes = mm.makeRe(pattern, {nonegate: true}).test(fixture);
var nmRes = nm.makeRe(pattern, {nonegate: true}).test(fixture);
var actual = nmRes === mmRes;
// minimatch is wrong on these
if (actual === false) {
// tie-breaker
if (nmRes === mm(fixture, pattern, {nonegate: true})) {
actual = true;
} else if (/^\?/.test(pattern) || /^\!/.test(fixture)) {
actual = true;
} else if (!isWindows() && !isTravis) {
actual = nmRes === nm.bash.isMatch(fixture, pattern, {nonegate: true});
} else {
this.skip();
return;
}
}
assert(actual, fixture + ' ' + pattern);
});
});
});
});