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

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

Issue 1448243002: Specialize Glob for the often case of suffix matching. (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
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.analyzer.src.util.glob; 5 library test.analyzer.src.util.glob;
6 6
7 import 'package:analyzer/src/util/glob.dart'; 7 import 'package:analyzer/src/util/glob.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 void test_starStar() { 56 void test_starStar() {
57 Glob glob = new Glob(r'/', r'**.dart'); 57 Glob glob = new Glob(r'/', r'**.dart');
58 expect(glob.matches(r'foo/bar.dart'), isTrue); 58 expect(glob.matches(r'foo/bar.dart'), isTrue);
59 expect(glob.matches(r'foo/bar/baz.dart'), isTrue); 59 expect(glob.matches(r'foo/bar/baz.dart'), isTrue);
60 expect(glob.matches(r'/foo/bar.dart'), isTrue); 60 expect(glob.matches(r'/foo/bar.dart'), isTrue);
61 expect(glob.matches(r'/foo/bar/baz.dart'), isTrue); 61 expect(glob.matches(r'/foo/bar/baz.dart'), isTrue);
62 // does not end with 'dart' 62 // does not end with 'dart'
63 expect(glob.matches(r'/web/foo.html'), isFalse); 63 expect(glob.matches(r'/web/foo.html'), isFalse);
64 } 64 }
65
66 void test_starStar_star() {
67 Glob glob = new Glob(r'/', r'**/*.dart');
68 expect(glob.matches(r'foo/bar.dart'), isTrue);
69 expect(glob.matches(r'foo/bar/baz.dart'), isTrue);
70 expect(glob.matches(r'/foo/bar.dart'), isTrue);
71 expect(glob.matches(r'/foo/bar/baz.dart'), isTrue);
72 // does not end with 'dart'
73 expect(glob.matches(r'/web/foo.html'), isFalse);
74 }
65 } 75 }
66 76
67 @reflectiveTest 77 @reflectiveTest
68 class GlobWindowsTest { 78 class GlobWindowsTest {
69 void test_case() { 79 void test_case() {
70 Glob glob = new Glob(r'\', r'**.dart'); 80 Glob glob = new Glob(r'\', r'**.dart');
71 expect(glob.matches(r'aaa.dart'), isTrue); 81 expect(glob.matches(r'aaa.dart'), isTrue);
72 expect(glob.matches(r'bbb.DART'), isTrue); 82 expect(glob.matches(r'bbb.DART'), isTrue);
73 expect(glob.matches(r'ccc.dArT'), isTrue); 83 expect(glob.matches(r'ccc.dArT'), isTrue);
74 expect(glob.matches(r'ddd.DaRt'), isTrue); 84 expect(glob.matches(r'ddd.DaRt'), isTrue);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void test_starStar() { 116 void test_starStar() {
107 Glob glob = new Glob(r'\', r'**.dart'); 117 Glob glob = new Glob(r'\', r'**.dart');
108 expect(glob.matches(r'foo\bar.dart'), isTrue); 118 expect(glob.matches(r'foo\bar.dart'), isTrue);
109 expect(glob.matches(r'foo\bar\baz.dart'), isTrue); 119 expect(glob.matches(r'foo\bar\baz.dart'), isTrue);
110 expect(glob.matches(r'C:\foo\bar.dart'), isTrue); 120 expect(glob.matches(r'C:\foo\bar.dart'), isTrue);
111 expect(glob.matches(r'C:\foo\bar\baz.dart'), isTrue); 121 expect(glob.matches(r'C:\foo\bar\baz.dart'), isTrue);
112 // does not end with 'dart' 122 // does not end with 'dart'
113 expect(glob.matches(r'C:\web\foo.html'), isFalse); 123 expect(glob.matches(r'C:\web\foo.html'), isFalse);
114 } 124 }
115 } 125 }
OLDNEW
« pkg/analyzer/lib/src/util/glob.dart ('K') | « pkg/analyzer/lib/src/util/glob.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698