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

Unified Diff: pkg/glob/test/match_test.dart

Issue 533323003: Fix glob match and parse tests for Windows and URL styles. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/glob/test/parse_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/glob/test/match_test.dart
diff --git a/pkg/glob/test/match_test.dart b/pkg/glob/test/match_test.dart
index eeb307d8d31d28ec5f63f6ff38780062b7942223..ad9dcf3e116f8b0ad4138fe50c175d3af31ab290 100644
--- a/pkg/glob/test/match_test.dart
+++ b/pkg/glob/test/match_test.dart
@@ -6,8 +6,12 @@ import 'package:glob/glob.dart';
import 'package:path/path.dart' as p;
import 'package:unittest/unittest.dart';
-const ASCII_WITHOUT_SLASH = "\t\n\r !\"#\$%&'()*+`-.0123456789:;<=>?@ABCDEFGHIJ"
- "KLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+const RAW_ASCII_WITHOUT_SLASH = "\t\n\r !\"#\$%&'()*+`-.0123456789:;<=>?@ABCDEF"
+ "GHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+
+// URL-encode the path for a URL context.
+final asciiWithoutSlash = p.style == p.Style.url ?
+ Uri.encodeFull(RAW_ASCII_WITHOUT_SLASH) : RAW_ASCII_WITHOUT_SLASH;
void main() {
test("literals match exactly", () {
@@ -16,10 +20,15 @@ void main() {
expect("foo*", contains(new Glob(r"foo\*")));
});
+ test("backslashes match nothing on Windows", () {
+ expect(r"foo\bar",
+ isNot(contains(new Glob(r"foo\\bar", context: p.windows))));
+ });
+
group("star", () {
test("matches non-separator characters", () {
var glob = new Glob("*");
- expect(ASCII_WITHOUT_SLASH, contains(glob));
+ expect(asciiWithoutSlash, contains(glob));
});
test("matches the empty string", () {
@@ -36,7 +45,7 @@ void main() {
group("double star", () {
test("matches non-separator characters", () {
var glob = new Glob("**");
- expect(ASCII_WITHOUT_SLASH, contains(glob));
+ expect(asciiWithoutSlash, contains(glob));
});
test("matches the empty string", () {
@@ -65,7 +74,8 @@ void main() {
group("any char", () {
test("matches any non-separator character", () {
var glob = new Glob("foo?");
- for (var char in ASCII_WITHOUT_SLASH.split('')) {
+ for (var char in RAW_ASCII_WITHOUT_SLASH.split('')) {
+ if (p.style == p.Style.url) char = Uri.encodeFull(char);
expect("foo$char", contains(glob));
}
});
« no previous file with comments | « no previous file | pkg/glob/test/parse_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698