Files: c5c7a8ffadbd51aa28a5f3f096fe43f69405da44 / test / test-48-common / main.js
6114 bytesRaw
1 | |
2 | |
3 | /* eslint-disable no-multi-spaces */ |
4 | |
5 | 'use strict'; |
6 | |
7 | const assert = require('assert'); |
8 | const common = require('../../prelude/common.js'); |
9 | |
10 | function substituteMany (files) { |
11 | const d = common.retrieveDenominator(files); |
12 | return files.map((f) => common.substituteDenominator(f, d)); |
13 | } |
14 | |
15 | if (process.platform === 'win32') { |
16 | assert.equal('c:', common.normalizePath('c:')); |
17 | assert.equal('C:\\', common.normalizePath('c:\\')); |
18 | assert.equal('C:\\', common.normalizePath('c:\\\\')); |
19 | assert.equal('C:\\snapshot', common.normalizePath('c:\\snapshot')); |
20 | assert.equal('C:\\snapshoter', common.normalizePath('c:\\snapshoter')); |
21 | assert.equal('C:\\snapshot', common.normalizePath('c:\\snapshot\\')); |
22 | assert.equal('C:\\snapshoter', common.normalizePath('c:\\snapshoter\\')); |
23 | assert.equal('C:\\snapshot\\foo', common.normalizePath('c:\\snapshot\\\\foo')); |
24 | assert.equal('C:\\snapshot\\foo\\bar', common.normalizePath('c:\\snapshot\\\\foo\\\\bar\\/\\\\')); |
25 | |
26 | assert.equal(common.insideSnapshot('c:'), false); |
27 | assert.equal(common.insideSnapshot('c:\\'), false); |
28 | assert.equal(common.insideSnapshot('c:\\foo'), false); |
29 | assert.equal(common.insideSnapshot('c:\\foo\\snapshot'), false); |
30 | assert.equal(common.insideSnapshot('c:\\snapshot'), true); |
31 | assert.equal(common.insideSnapshot('c:\\snapshoter'), false); |
32 | assert.equal(common.insideSnapshot('c:\\snapshot\\'), true); |
33 | assert.equal(common.insideSnapshot('c:\\snapshoter\\'), false); |
34 | assert.equal(common.insideSnapshot('c:\\snapshot\\\\'), true); |
35 | assert.equal(common.insideSnapshot('c:\\snapshot\\foo'), true); |
36 | assert.equal(common.insideSnapshot('c:\\snapshoter\\foo'), false); |
37 | |
38 | assert.equal('c:\\', common.stripSnapshot('c:\\')); |
39 | assert.equal('c:\\\\', common.stripSnapshot('c:\\\\')); |
40 | assert.equal('C:\\**\\', common.stripSnapshot('c:\\snapshot')); |
41 | assert.equal('c:\\snapshoter', common.stripSnapshot('c:\\snapshoter')); |
42 | assert.equal('C:\\**\\', common.stripSnapshot('c:\\snapshot\\')); |
43 | assert.equal('c:\\snapshoter\\', common.stripSnapshot('c:\\snapshoter\\')); |
44 | assert.equal('C:\\**\\foo', common.stripSnapshot('c:\\snapshot\\\\foo')); |
45 | assert.equal('C:\\**\\foo\\bar', common.stripSnapshot('c:\\snapshot\\\\foo\\\\bar\\/\\\\')); |
46 | |
47 | assert.equal('C:\\snapshot', common.snapshotify('C:\\')); |
48 | assert.equal('C:\\snapshot\\foo', common.snapshotify('C:\\foo')); |
49 | assert.equal('C:\\snapshot\\foo\\bar', common.snapshotify('C:\\foo\\bar')); |
50 | |
51 | assert.equal('foo', common.removeUplevels('..\\foo')); |
52 | assert.equal('foo', common.removeUplevels('..\\..\\foo')); |
53 | assert.equal('.\\foo', common.removeUplevels('.\\foo')); |
54 | assert.equal('.', common.removeUplevels('.')); |
55 | assert.equal('.', common.removeUplevels('..')); |
56 | assert.equal('.', common.removeUplevels('..\\..')); |
57 | |
58 | assert.deepEqual(substituteMany( |
59 | [ 'C:\\long\\haired\\freaky\\people', 'C:\\long\\haired\\aliens' ]), |
60 | [ 'C:\\freaky\\people', 'C:\\aliens' ]); |
61 | |
62 | assert.deepEqual(substituteMany( |
63 | [ 'C:\\long\\haired\\freaky\\people', 'C:\\long\\hyphen\\sign' ]), |
64 | [ 'C:\\haired\\freaky\\people', 'C:\\hyphen\\sign' ]); |
65 | |
66 | assert.deepEqual(substituteMany( |
67 | [ 'C:\\long\\haired\\freaky\\people', 'D:\\long\\hyphen\\sign' ]), |
68 | [ 'C:\\long\\haired\\freaky\\people', 'D:\\long\\hyphen\\sign' ]); |
69 | } else { |
70 | assert.equal('/', common.normalizePath('/')); |
71 | assert.equal('/', common.normalizePath('//')); |
72 | assert.equal('/snapshot', common.normalizePath('/snapshot')); |
73 | assert.equal('/snapshoter', common.normalizePath('/snapshoter')); |
74 | assert.equal('/snapshot', common.normalizePath('/snapshot/')); |
75 | assert.equal('/snapshoter', common.normalizePath('/snapshoter/')); |
76 | assert.equal('/snapshot/foo', common.normalizePath('/snapshot//foo')); |
77 | assert.equal('/snapshot/foo/bar', common.normalizePath('/snapshot//foo//bar/\\//')); |
78 | |
79 | assert.equal(common.insideSnapshot(''), false); |
80 | assert.equal(common.insideSnapshot('/'), false); |
81 | assert.equal(common.insideSnapshot('/foo'), false); |
82 | assert.equal(common.insideSnapshot('/foo/snapshot'), false); |
83 | assert.equal(common.insideSnapshot('/snapshot'), true); |
84 | assert.equal(common.insideSnapshot('/snapshoter'), false); |
85 | assert.equal(common.insideSnapshot('/snapshot/'), true); |
86 | assert.equal(common.insideSnapshot('/snapshoter/'), false); |
87 | assert.equal(common.insideSnapshot('/snapshot//'), true); |
88 | assert.equal(common.insideSnapshot('/snapshot/foo'), true); |
89 | assert.equal(common.insideSnapshot('/snapshoter/foo'), false); |
90 | |
91 | assert.equal('/', common.stripSnapshot('/')); |
92 | assert.equal('//', common.stripSnapshot('//')); |
93 | assert.equal('/**/', common.stripSnapshot('/snapshot')); |
94 | assert.equal('/snapshoter', common.stripSnapshot('/snapshoter')); |
95 | assert.equal('/**/', common.stripSnapshot('/snapshot/')); |
96 | assert.equal('/snapshoter/', common.stripSnapshot('/snapshoter/')); |
97 | assert.equal('/**/foo', common.stripSnapshot('/snapshot//foo')); |
98 | assert.equal('/**/foo/bar', common.stripSnapshot('/snapshot//foo//bar/\\//')); |
99 | |
100 | assert.equal('/snapshot', common.snapshotify('/')); |
101 | assert.equal('/snapshot/foo', common.snapshotify('/foo')); |
102 | assert.equal('/snapshot/foo/bar', common.snapshotify('/foo/bar')); |
103 | |
104 | assert.equal('foo', common.removeUplevels('../foo')); |
105 | assert.equal('foo', common.removeUplevels('../../foo')); |
106 | assert.equal('./foo', common.removeUplevels('./foo')); |
107 | assert.equal('.', common.removeUplevels('.')); |
108 | assert.equal('.', common.removeUplevels('..')); |
109 | assert.equal('.', common.removeUplevels('../..')); |
110 | |
111 | assert.deepEqual(substituteMany( |
112 | [ '/long/haired/freaky/people', '/long/haired/aliens' ]), |
113 | [ '/freaky/people', '/aliens' ]); |
114 | |
115 | assert.deepEqual(substituteMany( |
116 | [ '/long/haired/freaky/people', '/long/hyphen/sign' ]), |
117 | [ '/haired/freaky/people', '/hyphen/sign' ]); |
118 | } |
119 |
Built with git-ssb-web