| OLD | NEW |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 library quiver.patttern.glob_test; | 15 library quiver.patttern.glob_test; |
| 16 | 16 |
| 17 import 'package:test/test.dart'; | 17 import 'package:test/test.dart'; |
| 18 import 'package:quiver/pattern.dart'; | 18 import 'package:quiver/pattern.dart'; |
| 19 | 19 |
| 20 main() { | 20 main() { |
| 21 group('Glob', () { | 21 group('Glob', () { |
| 22 test('should match "*" against sequences of word chars', () { | 22 test('should match "*" against sequences of word chars', () { |
| 23 expectGlob("*.html", | 23 expectGlob("*.html", matches: [ |
| 24 matches: [ | |
| 25 "a.html", | 24 "a.html", |
| 26 "_-\a.html", | 25 "_-\a.html", |
| 27 r"^$*?.html", | 26 r"^$*?.html", |
| 28 "()[]{}.html", | 27 "()[]{}.html", |
| 29 "↭.html", | 28 "↭.html", |
| 30 "\u21ad.html", | 29 "\u21ad.html", |
| 31 "♥.html", | 30 "♥.html", |
| 32 "\u2665.html" | 31 "\u2665.html" |
| 33 ], | 32 ], nonMatches: [ |
| 34 nonMatches: ["a.htm", "a.htmlx", "/a.html"]); | 33 "a.htm", |
| 34 "a.htmlx", |
| 35 "/a.html" |
| 36 ]); |
| 35 expectGlob("foo.*", | 37 expectGlob("foo.*", |
| 36 matches: ["foo.html"], | 38 matches: ["foo.html"], |
| 37 nonMatches: ["afoo.html", "foo/a.html", "foo.html/a"]); | 39 nonMatches: ["afoo.html", "foo/a.html", "foo.html/a"]); |
| 38 }); | 40 }); |
| 39 | 41 |
| 40 test('should match "**" against paths', () { | 42 test('should match "**" against paths', () { |
| 41 expectGlob("**/*.html", | 43 expectGlob("**/*.html", |
| 42 matches: ["/a.html", "a/b.html", "a/b/c.html", "a/b/c.html/d.html"], | 44 matches: ["/a.html", "a/b.html", "a/b/c.html", "a/b/c.html/d.html"], |
| 43 nonMatches: ["a.html", "a/b.html/c"]); | 45 nonMatches: ["a.html", "a/b.html/c"]); |
| 44 }); | 46 }); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 expect(match.start, 0); | 62 expect(match.start, 0); |
| 61 expect(match.end, str.length); | 63 expect(match.end, str.length); |
| 62 } | 64 } |
| 63 for (var str in nonMatches) { | 65 for (var str in nonMatches) { |
| 64 expect(glob.hasMatch(str), false); | 66 expect(glob.hasMatch(str), false); |
| 65 var m = new List.from(glob.allMatches(str)); | 67 var m = new List.from(glob.allMatches(str)); |
| 66 expect(m.length, 0); | 68 expect(m.length, 0); |
| 67 expect(glob.matchAsPrefix(str), null); | 69 expect(glob.matchAsPrefix(str), null); |
| 68 } | 70 } |
| 69 } | 71 } |
| OLD | NEW |