| Index: packages/glob/test/list_test.dart
|
| diff --git a/packages/glob/test/list_test.dart b/packages/glob/test/list_test.dart
|
| index 33275243a759cec0b8746ef343f8c05c16f4735e..d59e273d0240a3d3cbb0755573a9a5480b0435a7 100644
|
| --- a/packages/glob/test/list_test.dart
|
| +++ b/packages/glob/test/list_test.dart
|
| @@ -52,6 +52,29 @@ void main() {
|
| });
|
| });
|
|
|
| + group("when case-sensitive", () {
|
| + test("lists literals case-sensitively", () {
|
| + schedule(() {
|
| + expect(new Glob("foo/BAZ/qux", caseSensitive: true).listSync,
|
| + throwsA(new isInstanceOf<FileSystemException>()));
|
| + });
|
| + });
|
| +
|
| + test("lists ranges case-sensitively", () {
|
| + schedule(() {
|
| + expect(new Glob("foo/[BX][A-Z]z/qux", caseSensitive: true).listSync,
|
| + throwsA(new isInstanceOf<FileSystemException>()));
|
| + });
|
| + });
|
| +
|
| + test("options preserve case-sensitivity", () {
|
| + schedule(() {
|
| + expect(new Glob("foo/{BAZ,ZAP}/qux", caseSensitive: true).listSync,
|
| + throwsA(new isInstanceOf<FileSystemException>()));
|
| + });
|
| + });
|
| + });
|
| +
|
| syncAndAsync((list) {
|
| group("literals", () {
|
| test("lists a single literal", () {
|
| @@ -252,6 +275,19 @@ void main() {
|
| ])));
|
| });
|
|
|
| + // Regression test for #4.
|
| + test("lists an absolute case-insensitive glob", () {
|
| + expect(schedule(() {
|
| + var pattern = separatorToForwardSlash(
|
| + p.absolute(p.join(sandbox, 'foo/Baz/**')));
|
| +
|
| + return list(pattern, caseSensitive: false);
|
| + }), completion(unorderedEquals([
|
| + p.join("foo", "baz", "bang"),
|
| + p.join("foo", "baz", "qux")
|
| + ])));
|
| + });
|
| +
|
| test("lists a subdirectory that sometimes exists", () {
|
| d.dir("top", [
|
| d.dir("dir1", [
|
| @@ -263,34 +299,63 @@ void main() {
|
| expect(list("top/*/subdir/**"),
|
| completion(equals([p.join("top", "dir1", "subdir", "file")])));
|
| });
|
| +
|
| + group("when case-insensitive", () {
|
| + test("lists literals case-insensitively", () {
|
| + expect(list("foo/baz/qux", caseSensitive: false),
|
| + completion(equals([p.join("foo", "baz", "qux")])));
|
| + expect(list("foo/BAZ/qux", caseSensitive: false),
|
| + completion(equals([p.join("foo", "baz", "qux")])));
|
| + });
|
| +
|
| + test("lists ranges case-insensitively", () {
|
| + expect(list("foo/[bx][a-z]z/qux", caseSensitive: false),
|
| + completion(equals([p.join("foo", "baz", "qux")])));
|
| + expect(list("foo/[BX][A-Z]z/qux", caseSensitive: false),
|
| + completion(equals([p.join("foo", "baz", "qux")])));
|
| + });
|
| +
|
| + test("options preserve case-insensitivity", () {
|
| + expect(list("foo/{bar,baz}/qux", caseSensitive: false),
|
| + completion(equals([p.join("foo", "baz", "qux")])));
|
| + expect(list("foo/{BAR,BAZ}/qux", caseSensitive: false),
|
| + completion(equals([p.join("foo", "baz", "qux")])));
|
| + });
|
| + });
|
| });
|
| }
|
|
|
| typedef Future<List<String>> ListFn(String glob,
|
| - {bool recursive, bool followLinks});
|
| + {bool recursive, bool followLinks, bool caseSensitive});
|
|
|
| /// Runs [callback] in two groups with two values of [listFn]: one that uses
|
| /// [Glob.list], one that uses [Glob.listSync].
|
| void syncAndAsync(callback(ListFn listFn)) {
|
| group("async", () {
|
| - callback((glob, {recursive: false, followLinks: true}) {
|
| + callback((pattern, {recursive: false, followLinks: true, caseSensitive}) {
|
| return schedule(() {
|
| - return new Glob(glob, recursive: recursive)
|
| + var glob = new Glob(pattern,
|
| + recursive: recursive, caseSensitive: caseSensitive);
|
| +
|
| + return glob
|
| .list(root: sandbox, followLinks: followLinks)
|
| .map((entity) => p.relative(entity.path, from: sandbox))
|
| .toList();
|
| - }, 'listing $glob');
|
| + }, 'listing $pattern');
|
| });
|
| });
|
|
|
| group("sync", () {
|
| - callback((glob, {recursive: false, followLinks: true}) {
|
| + callback((pattern, {recursive: false, followLinks: true, caseSensitive}) {
|
| return schedule(() {
|
| - return new Glob(glob, recursive: recursive)
|
| + var glob = new Glob(pattern,
|
| + recursive: recursive, caseSensitive: caseSensitive);
|
| +
|
| + return glob
|
| .listSync(root: sandbox, followLinks: followLinks)
|
| .map((entity) => p.relative(entity.path, from: sandbox))
|
| .toList();
|
| - }, 'listing $glob');
|
| + }, 'listing $pattern');
|
| });
|
| });
|
| }
|
|
|