OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 import 'dart:io'; | |
6 | |
7 import 'package:glob/glob.dart'; | 5 import 'package:glob/glob.dart'; |
8 import 'package:path/path.dart' as p; | 6 import 'package:path/path.dart' as p; |
9 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
10 | 8 |
11 const ASCII_WITHOUT_SLASH = "\t\n\r !\"#\$%&'()*+`-.0123456789:;<=>?@ABCDEFGHIJ" | 9 const ASCII_WITHOUT_SLASH = "\t\n\r !\"#\$%&'()*+`-.0123456789:;<=>?@ABCDEFGHIJ" |
12 "KLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; | 10 "KLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; |
13 | 11 |
14 void main() { | 12 void main() { |
15 test("literals match exactly", () { | 13 test("literals match exactly", () { |
16 expect("foo", contains(new Glob("foo"))); | 14 expect("foo", contains(new Glob("foo"))); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 }); | 218 }); |
221 }); | 219 }); |
222 | 220 |
223 test("an absolute path can be matched by a relative glob", () { | 221 test("an absolute path can be matched by a relative glob", () { |
224 var path = p.absolute('foo/bar'); | 222 var path = p.absolute('foo/bar'); |
225 expect(path, contains(new Glob("foo/bar"))); | 223 expect(path, contains(new Glob("foo/bar"))); |
226 }); | 224 }); |
227 | 225 |
228 test("a relative path can be matched by an absolute glob", () { | 226 test("a relative path can be matched by an absolute glob", () { |
229 var pattern = p.absolute('foo/bar'); | 227 var pattern = p.absolute('foo/bar'); |
230 if (Platform.isWindows) pattern = pattern.replaceAll('\\', '/'); | 228 if (p.style == p.Style.windows) pattern = pattern.replaceAll('\\', '/'); |
231 expect('foo/bar', contains(new Glob(pattern))); | 229 expect('foo/bar', contains(new Glob(pattern))); |
232 }); | 230 }); |
233 | 231 |
234 group("with recursive: true", () { | 232 group("with recursive: true", () { |
235 var glob = new Glob("foo/bar", recursive: true); | 233 var glob = new Glob("foo/bar", recursive: true); |
236 | 234 |
237 test("still matches basic files", () { | 235 test("still matches basic files", () { |
238 expect("foo/bar", contains(glob)); | 236 expect("foo/bar", contains(glob)); |
239 }); | 237 }); |
240 | 238 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 expect(r"http://foo.com/bar", | 275 expect(r"http://foo.com/bar", |
278 contains(new Glob("http://**", context: p.url))); | 276 contains(new Glob("http://**", context: p.url))); |
279 expect(r"http://foo.com/bar", | 277 expect(r"http://foo.com/bar", |
280 contains(new Glob("http://foo.com/**", context: p.url))); | 278 contains(new Glob("http://foo.com/**", context: p.url))); |
281 | 279 |
282 expect("/foo/bar", contains(new Glob("/foo/bar", context: p.url))); | 280 expect("/foo/bar", contains(new Glob("/foo/bar", context: p.url))); |
283 expect("/foo/bar", isNot(contains(new Glob("**", context: p.url)))); | 281 expect("/foo/bar", isNot(contains(new Glob("**", context: p.url)))); |
284 expect("/foo/bar", contains(new Glob("/**", context: p.url))); | 282 expect("/foo/bar", contains(new Glob("/**", context: p.url))); |
285 }); | 283 }); |
286 } | 284 } |
OLD | NEW |