Skip to content

Commit fadb8f5

Browse files
es128phated
authored andcommitted
test: add more braces/brackets tests
1 parent 99ec9fe commit fadb8f5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test.js

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('glob-parent', function() {
3535
assert.equal(gp('/root/path/to/*.js'), '/root/path/to');
3636
assert.equal(gp('chapter/foo [bar]/'), 'chapter');
3737
assert.equal(gp('path/[a-z]'), 'path');
38+
assert.equal(gp('[a-z]'), '.');
3839
assert.equal(gp('path/{to,from}'), 'path');
3940
assert.equal(gp('path/(to|from)'), 'path');
4041
assert.equal(gp('path/(foo bar)/subdir/foo.*'), 'path/(foo bar)/subdir');
@@ -57,6 +58,7 @@ describe('glob-parent', function() {
5758
assert.equal(gp('path/**/subdir/foo.*'), 'path');
5859
assert.equal(gp('path/subdir/**/foo.js'), 'path/subdir');
5960
assert.equal(gp('path/!subdir/foo.js'), 'path/!subdir');
61+
assert.equal(gp('path/{foo,bar}/'), 'path');
6062
});
6163

6264
it('should respect escaped characters', function() {
@@ -67,22 +69,44 @@ describe('glob-parent', function() {
6769
assert.equal(gp('path/\\*\\(a\\|b\\)/subdir/foo.*'), 'path/*(a|b)/subdir');
6870
assert.equal(gp('path/\\[foo bar\\]/subdir/foo.*'), 'path/[foo bar]/subdir');
6971
assert.equal(gp('path/\\[bar]/'), 'path/[bar]');
72+
assert.equal(gp('path/\\[bar]'), 'path/[bar]');
73+
assert.equal(gp('[bar]'), '.');
74+
assert.equal(gp('[bar]/'), '.');
75+
assert.equal(gp('\\[bar]'), '[bar]');
76+
assert.equal(gp('[bar\\]'), '.');
7077
assert.equal(gp('path/foo \\[bar]/'), 'path/foo [bar]');
78+
assert.equal(gp('path/\\{foo,bar}/'), 'path/{foo,bar}');
79+
assert.equal(gp('\\{foo,bar}/'), '{foo,bar}');
80+
assert.equal(gp('\\{foo,bar\\}'), '{foo,bar}');
81+
assert.equal(gp('{foo,bar\\}'), '.');
7182
});
7283

7384
it('should respect glob enclosures with embedded separators', function() {
7485
assert.equal(gp('path/{,/,bar/baz,qux}/'), 'path');
86+
assert.equal(gp('path/\\{,/,bar/baz,qux}/'), 'path/{,/,bar/baz,qux}');
7587
assert.equal(gp('path/\\{,/,bar/baz,qux\\}/'), 'path/{,/,bar/baz,qux}');
7688
assert.equal(gp('/{,/,bar/baz,qux}/'), '/');
7789
assert.equal(gp('/\\{,/,bar/baz,qux}/'), '/{,/,bar/baz,qux}');
7890
assert.equal(gp('{,/,bar/baz,qux}'), '.');
7991
assert.equal(gp('\\{,/,bar/baz,qux\\}'), '{,/,bar/baz,qux}');
92+
assert.equal(gp('\\{,/,bar/baz,qux}/'), '{,/,bar/baz,qux}');
8093
assert.equal(gp('path/foo[a\\\/]/'), 'path');
8194
assert.equal(gp('path/foo\\[a\\\/]/'), 'path/foo[a\\\/]');
8295
assert.equal(gp('foo[a\\\/]'), '.');
8396
assert.equal(gp('foo\\[a\\\/]'), 'foo[a\\\/]');
8497
});
8598

99+
it('should handle nested braces', function() {
100+
assert.equal(gp('path/{../,./,{bar,/baz\\},qux\\}/'), 'path');
101+
assert.equal(gp('path/{../,./,\\{bar,/baz},qux}/'), 'path');
102+
assert.equal(gp('path/\\{../,./,\\{bar,/baz\\},qux\\}/'), 'path/{../,./,{bar,/baz},qux}');
103+
assert.equal(gp('{../,./,{bar,/baz\\},qux\\}/'), '.');
104+
assert.equal(gp('{../,./,{bar,/baz\\},qux\\}'), '.');
105+
assert.equal(gp('path/{,/,bar/{baz,qux\\}}/'), 'path');
106+
assert.equal(gp('path/{,/,bar/{baz,qux}\\}/'), 'path');
107+
//assert.equal(gp('path/\\{../,./,{bar,/baz},qux}/'), 'path');
108+
});
109+
86110
it('should return parent dirname from non-glob paths', function() {
87111
assert.equal(gp('path'), '.');
88112
assert.equal(gp('path/foo'), 'path');

0 commit comments

Comments
 (0)