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

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/test/match_test.dart ('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("fo1", contains(bang));
Bob Nystrom 2014/08/27 22:16:44 Use something other than 1 here.
nweiz 2014/09/02 19:48:16 Done.
22
23 var caret = new Glob("fo[^a-z]");
24 expect("foo", isNot(contains(bang)));
25 expect("fo1", 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 });
46
47 test("disallows dangling ]", () {
48 expect(() => new Glob(r"abc]"), throwsFormatException);
49 });
Bob Nystrom 2014/08/27 22:16:44 Test "[-]", "[a-]", "[-b]", and "[-".
nweiz 2014/09/02 19:48:16 I think the first three are actually expected to w
50 });
51
52 group("options", () {
53 test("allows empty branches", () {
54 var glob = new Glob("foo{,bar}");
55 expect("foo", contains(glob));
56 expect("foobar", contains(glob));
57 });
58
59 test("disallows empty options", () {
60 expect(() => new Glob("{}"), throwsFormatException);
61 });
62
63 test("disallows single options", () {
64 expect(() => new Glob("{foo}"), throwsFormatException);
65 });
66
67 test("disallows unclosed options", () {
68 expect(() => new Glob("{foo,bar"), throwsFormatException);
69 });
70
71 test("disallows dangling }", () {
72 expect(() => new Glob("foo}"), throwsFormatException);
73 });
74
75 test("disallows dangling ] in options", () {
76 expect(() => new Glob(r"{abc]}"), throwsFormatException);
77 });
Bob Nystrom 2014/08/27 22:16:45 Test "{abc,".
nweiz 2014/09/02 19:48:16 Done.
78 });
79
80 test("disallows unescaped parens", () {
81 expect(() => new Glob("foo(bar"), throwsFormatException);
82 expect(() => new Glob("foo)bar"), throwsFormatException);
83 });
84 }
OLDNEW
« pkg/glob/test/match_test.dart ('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