Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80556 views
1
var test = require('tape');
2
var expand = require('..');
3
var fs = require('fs');
4
var resfile = __dirname + '/bash-results.txt';
5
var cases = fs.readFileSync(resfile, 'utf8').split('><><><><');
6
7
// throw away the EOF marker
8
cases.pop()
9
10
test('matches bash expansions', function(t) {
11
cases.forEach(function(testcase) {
12
var set = testcase.split('\n');
13
var pattern = set.shift();
14
var actual = expand(pattern);
15
16
// If it expands to the empty string, then it's actually
17
// just nothing, but Bash is a singly typed language, so
18
// "nothing" is the same as "".
19
if (set.length === 1 && set[0] === '') {
20
set = []
21
} else {
22
// otherwise, strip off the [] that were added so that
23
// "" expansions would be preserved properly.
24
set = set.map(function (s) {
25
return s.replace(/^\[|\]$/g, '')
26
})
27
}
28
29
t.same(actual, set, pattern);
30
});
31
t.end();
32
})
33
34