Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: pkg/glob/test/parse_test.dart

Issue 506993004: Create a glob package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« pkg/glob/README.md ('K') | « pkg/glob/test/match_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:glob/glob.dart';
6 import 'package:unittest/unittest.dart';
7
8 void main() {
9 test("supports backslash-escaped characters", () {
10 expect(r"\*[]{,}?()", contains(new Glob(r"\\\*\[\]\{\,\}\?\(\)")));
11 });
12
13 test("disallows an empty glob", () {
14 expect(() => new Glob(""), throwsFormatException);
15 });
16
17 group("range", () {
18 test("supports either ^ or ! for negated ranges", () {
19 var bang = new Glob("fo[!a-z]");
20 expect("foo", isNot(contains(bang)));
21 expect("fo2", contains(bang));
22
23 var caret = new Glob("fo[^a-z]");
24 expect("foo", isNot(contains(bang)));
25 expect("fo2", contains(bang));
26 });
27
28 test("supports backslash-escaped characters", () {
29 var glob = new Glob(r"fo[\*\--\]]");
30 expect("fo]", contains(glob));
31 expect("fo-", contains(glob));
32 expect("fo*", contains(glob));
33 });
34
35 test("disallows inverted ranges", () {
36 expect(() => new Glob(r"[z-a]"), throwsFormatException);
37 });
38
39 test("disallows empty ranges", () {
40 expect(() => new Glob(r"[]"), throwsFormatException);
41 });
42
43 test("disallows unclosed ranges", () {
44 expect(() => new Glob(r"[abc"), throwsFormatException);
45 expect(() => new Glob(r"[-"), throwsFormatException);
46 });
47
48 test("disallows dangling ]", () {
49 expect(() => new Glob(r"abc]"), throwsFormatException);
50 });
51 });
52
53 group("options", () {
54 test("allows empty branches", () {
55 var glob = new Glob("foo{,bar}");
56 expect("foo", contains(glob));
57 expect("foobar", contains(glob));
58 });
59
60 test("disallows empty options", () {
61 expect(() => new Glob("{}"), throwsFormatException);
62 });
63
64 test("disallows single options", () {
65 expect(() => new Glob("{foo}"), throwsFormatException);
66 });
67
68 test("disallows unclosed options", () {
69 expect(() => new Glob("{foo,bar"), throwsFormatException);
70 expect(() => new Glob("{foo,"), throwsFormatException);
71 });
72
73 test("disallows dangling }", () {
74 expect(() => new Glob("foo}"), throwsFormatException);
75 });
76
77 test("disallows dangling ] in options", () {
78 expect(() => new Glob(r"{abc]}"), throwsFormatException);
79 });
80 });
81
82 test("disallows unescaped parens", () {
83 expect(() => new Glob("foo(bar"), throwsFormatException);
84 expect(() => new Glob("foo)bar"), throwsFormatException);
85 });
86 }
OLDNEW
« pkg/glob/README.md ('K') | « pkg/glob/test/match_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698