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 'package:glob/glob.dart'; | 5 import 'package:glob/glob.dart'; |
| 6 import 'package:path/path.dart' as p; |
6 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
7 | 8 |
8 void main() { | 9 void main() { |
9 group("Glob.quote()", () { | 10 group("Glob.quote()", () { |
10 test("quotes all active characters", () { | 11 test("quotes all active characters", () { |
11 expect(Glob.quote("*{[?\\}],-"), equals(r"\*\{\[\?\\\}\]\,\-")); | 12 expect(Glob.quote("*{[?\\}],-"), equals(r"\*\{\[\?\\\}\]\,\-")); |
12 }); | 13 }); |
13 | 14 |
14 test("doesn't quote inactive characters", () { | 15 test("doesn't quote inactive characters", () { |
15 expect(Glob.quote("abc~`_+="), equals("abc~`_+=")); | 16 expect(Glob.quote("abc~`_+="), equals("abc~`_+=")); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 expect(match.groups([0]), equals(["foobar"])); | 85 expect(match.groups([0]), equals(["foobar"])); |
85 }); | 86 }); |
86 | 87 |
87 test("throws a range error for an invalid group", () { | 88 test("throws a range error for an invalid group", () { |
88 expect(() => match[1], throwsRangeError); | 89 expect(() => match[1], throwsRangeError); |
89 expect(() => match[-1], throwsRangeError); | 90 expect(() => match[-1], throwsRangeError); |
90 expect(() => match.group(1), throwsRangeError); | 91 expect(() => match.group(1), throwsRangeError); |
91 expect(() => match.groups([1]), throwsRangeError); | 92 expect(() => match.groups([1]), throwsRangeError); |
92 }); | 93 }); |
93 }); | 94 }); |
| 95 |
| 96 test("globs are case-sensitive by default for Posix and URL contexts", () { |
| 97 expect("foo", contains(new Glob("foo", context: p.posix))); |
| 98 expect("FOO", isNot(contains(new Glob("foo", context: p.posix)))); |
| 99 expect("foo", isNot(contains(new Glob("FOO", context: p.posix)))); |
| 100 |
| 101 expect("foo", contains(new Glob("foo", context: p.url))); |
| 102 expect("FOO", isNot(contains(new Glob("foo", context: p.url)))); |
| 103 expect("foo", isNot(contains(new Glob("FOO", context: p.url)))); |
| 104 }); |
| 105 |
| 106 test("globs are case-insensitive by default for Windows contexts", () { |
| 107 expect("foo", contains(new Glob("foo", context: p.windows))); |
| 108 expect("FOO", contains(new Glob("foo", context: p.windows))); |
| 109 expect("foo", contains(new Glob("FOO", context: p.windows))); |
| 110 }); |
94 } | 111 } |
OLD | NEW |