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

Side by Side Diff: pkg/analyzer/test/src/util/glob_test.dart

Issue 1452473002: Replace Glob implementation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 library test.analyzer.src.util.glob;
6
7 import 'package:analyzer/src/util/glob.dart';
8 import 'package:unittest/unittest.dart';
9
10 import '../../reflective_tests.dart';
11 import '../../utils.dart';
12
13 main() {
14 initializeTestEnvironment();
15 runReflectiveTests(GlobPosixTest);
16 runReflectiveTests(GlobWindowsTest);
17 }
18
19 @reflectiveTest
20 class GlobPosixTest {
21 void test_question() {
22 Glob glob = new Glob(r'/', r'?.dart');
23 expect(glob.matches(r'a.dart'), isTrue);
24 expect(glob.matches(r'b.dart'), isTrue);
25 expect(glob.matches(r'cc.dart'), isFalse);
26 }
27
28 void test_specialChars() {
29 Glob glob = new Glob(r'/', r'*.dart');
30 expect(glob.matches(r'a.dart'), isTrue);
31 expect(glob.matches('_-\a.dart'), isTrue);
32 expect(glob.matches(r'^$*?.dart'), isTrue);
33 expect(glob.matches(r'()[]{}.dart'), isTrue);
34 expect(glob.matches('\u2665.dart'), isTrue);
35 }
36
37 void test_star() {
38 Glob glob = new Glob(r'/', r'web/*.dart');
39 expect(glob.matches(r'web/foo.dart'), isTrue);
40 expect(glob.matches(r'web/barbaz.dart'), isTrue);
41 // does not end with 'dart'
42 expect(glob.matches(r'web/foo.html'), isFalse);
43 // not in 'web'
44 expect(glob.matches(r'lib/foo.dart'), isFalse);
45 expect(glob.matches(r'/web/foo.dart'), isFalse);
46 // in sub-folder
47 expect(glob.matches(r'web/sub/foo.dart'), isFalse);
48 }
49
50 void test_starStar() {
51 Glob glob = new Glob(r'/', r'**.dart');
52 expect(glob.matches(r'foo/bar.dart'), isTrue);
53 expect(glob.matches(r'foo/bar/baz.dart'), isTrue);
54 // does not end with 'dart'
55 expect(glob.matches(r'web/foo.html'), isFalse);
56 }
57 }
58
59 @reflectiveTest
60 class GlobWindowsTest {
Brian Wilkerson 2015/11/15 16:27:47 None of the paths in these tests contain drive let
scheglov 2015/11/15 18:42:11 Done.
61 void test_case() {
62 Glob glob = new Glob(r'\', r'**.dart');
63 expect(glob.matches(r'aaa.dart'), isTrue);
64 expect(glob.matches(r'bbb.DART'), isTrue);
65 expect(glob.matches(r'ccc.dArT'), isTrue);
66 expect(glob.matches(r'ddd.DaRt'), isTrue);
67 }
68
69 void test_question() {
70 Glob glob = new Glob(r'\', r'?.dart');
71 expect(glob.matches(r'a.dart'), isTrue);
72 expect(glob.matches(r'b.dart'), isTrue);
73 expect(glob.matches(r'cc.dart'), isFalse);
74 }
75
76 void test_specialChars() {
77 Glob glob = new Glob(r'\', r'*.dart');
78 expect(glob.matches(r'a.dart'), isTrue);
79 expect(glob.matches('_-\a.dart'), isTrue);
80 expect(glob.matches(r'^$*?.dart'), isTrue);
81 expect(glob.matches(r'()[]{}.dart'), isTrue);
82 expect(glob.matches('\u2665.dart'), isTrue);
83 }
84
85 void test_star() {
86 Glob glob = new Glob(r'\', r'web/*.dart');
87 expect(glob.matches(r'web\foo.dart'), isTrue);
88 expect(glob.matches(r'web\barbaz.dart'), isTrue);
89 // does not end with 'dart'
90 expect(glob.matches(r'web\foo.html'), isFalse);
91 // not in 'web'
92 expect(glob.matches(r'lib\foo.dart'), isFalse);
93 expect(glob.matches(r'\web\foo.dart'), isFalse);
94 // in sub-folder
95 expect(glob.matches(r'web\sub\foo.dart'), isFalse);
96 }
97
98 void test_starStar() {
99 Glob glob = new Glob(r'\', r'**.dart');
100 expect(glob.matches(r'foo\bar.dart'), isTrue);
101 expect(glob.matches(r'foo\bar\baz.dart'), isTrue);
102 // does not end with 'dart'
103 expect(glob.matches(r'web\foo.html'), isFalse);
104 }
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698