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

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

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « packages/glob/test/match_test.dart ('k') | packages/html/.gitignore » ('j') | 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:path/path.dart' as p;
7 import 'package:test/test.dart';
8
9 void main() {
10 test("supports backslash-escaped characters", () {
11 expect(r"*[]{,}?()", contains(new Glob(r"\*\[\]\{\,\}\?\(\)")));
12 if (p.style != p.Style.windows) {
13 expect(r"foo\bar", contains(new Glob(r"foo\\bar")));
14 }
15 });
16
17 test("disallows an empty glob", () {
18 expect(() => new Glob(""), throwsFormatException);
19 });
20
21 group("range", () {
22 test("supports either ^ or ! for negated ranges", () {
23 var bang = new Glob("fo[!a-z]");
24 expect("foo", isNot(contains(bang)));
25 expect("fo2", contains(bang));
26
27 var caret = new Glob("fo[^a-z]");
28 expect("foo", isNot(contains(caret)));
29 expect("fo2", contains(caret));
30 });
31
32 test("supports backslash-escaped characters", () {
33 var glob = new Glob(r"fo[\*\--\]]");
34 expect("fo]", contains(glob));
35 expect("fo-", contains(glob));
36 expect("fo*", contains(glob));
37 });
38
39 test("disallows inverted ranges", () {
40 expect(() => new Glob(r"[z-a]"), throwsFormatException);
41 });
42
43 test("disallows empty ranges", () {
44 expect(() => new Glob(r"[]"), throwsFormatException);
45 });
46
47 test("disallows unclosed ranges", () {
48 expect(() => new Glob(r"[abc"), throwsFormatException);
49 expect(() => new Glob(r"[-"), throwsFormatException);
50 });
51
52 test("disallows dangling ]", () {
53 expect(() => new Glob(r"abc]"), throwsFormatException);
54 });
55
56 test("disallows explicit /", () {
57 expect(() => new Glob(r"[/]"), throwsFormatException);
58 expect(() => new Glob(r"[ -/]"), throwsFormatException);
59 expect(() => new Glob(r"[/-~]"), throwsFormatException);
60 });
61 });
62
63 group("options", () {
64 test("allows empty branches", () {
65 var glob = new Glob("foo{,bar}");
66 expect("foo", contains(glob));
67 expect("foobar", contains(glob));
68 });
69
70 test("disallows empty options", () {
71 expect(() => new Glob("{}"), throwsFormatException);
72 });
73
74 test("disallows single options", () {
75 expect(() => new Glob("{foo}"), throwsFormatException);
76 });
77
78 test("disallows unclosed options", () {
79 expect(() => new Glob("{foo,bar"), throwsFormatException);
80 expect(() => new Glob("{foo,"), throwsFormatException);
81 });
82
83 test("disallows dangling }", () {
84 expect(() => new Glob("foo}"), throwsFormatException);
85 });
86
87 test("disallows dangling ] in options", () {
88 expect(() => new Glob(r"{abc]}"), throwsFormatException);
89 });
90 });
91
92 test("disallows unescaped parens", () {
93 expect(() => new Glob("foo(bar"), throwsFormatException);
94 expect(() => new Glob("foo)bar"), throwsFormatException);
95 });
96 }
OLDNEW
« no previous file with comments | « packages/glob/test/match_test.dart ('k') | packages/html/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698