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

Unified Diff: packages/glob/test/glob_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 | « packages/glob/pubspec.yaml ('k') | packages/glob/test/list_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/glob/test/glob_test.dart
diff --git a/packages/glob/test/glob_test.dart b/packages/glob/test/glob_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a742f20fd9ca2abc024ddfd477859ae9c8544696
--- /dev/null
+++ b/packages/glob/test/glob_test.dart
@@ -0,0 +1,94 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:glob/glob.dart';
+import 'package:test/test.dart';
+
+void main() {
+ group("Glob.quote()", () {
+ test("quotes all active characters", () {
+ expect(Glob.quote("*{[?\\}],-"), equals(r"\*\{\[\?\\\}\]\,\-"));
+ });
+
+ test("doesn't quote inactive characters", () {
+ expect(Glob.quote("abc~`_+="), equals("abc~`_+="));
+ });
+ });
+
+ group("Glob.matches()", () {
+ test("returns whether the path matches the glob", () {
+ var glob = new Glob("foo*");
+ expect(glob.matches("foobar"), isTrue);
+ expect(glob.matches("baz"), isFalse);
+ });
+
+ test("only matches the entire path", () {
+ var glob = new Glob("foo");
+ expect(glob.matches("foo/bar"), isFalse);
+ expect(glob.matches("bar/foo"), isFalse);
+ });
+ });
+
+ group("Glob.matchAsPrefix()", () {
+ test("returns a match if the path matches the glob", () {
+ var glob = new Glob("foo*");
+ expect(glob.matchAsPrefix("foobar"), new isInstanceOf<Match>());
+ expect(glob.matchAsPrefix("baz"), isNull);
+ });
+
+ test("returns null for start > 0", () {
+ var glob = new Glob("*");
+ expect(glob.matchAsPrefix("foobar", 1), isNull);
+ });
+ });
+
+ group("Glob.allMatches()", () {
+ test("returns a single match if the path matches the glob", () {
+ var matches = new Glob("foo*").allMatches("foobar");
+ expect(matches, hasLength(1));
+ expect(matches.first, new isInstanceOf<Match>());
+ });
+
+ test("returns an empty list if the path doesn't match the glob", () {
+ expect(new Glob("foo*").allMatches("baz"), isEmpty);
+ });
+
+ test("returns no matches for start > 0", () {
+ var glob = new Glob("*");
+ expect(glob.allMatches("foobar", 1), isEmpty);
+ });
+ });
+
+ group("GlobMatch", () {
+ var glob = new Glob("foo*");
+ var match = glob.matchAsPrefix("foobar");
+
+ test("returns the string as input", () {
+ expect(match.input, equals("foobar"));
+ });
+
+ test("returns the glob as the pattern", () {
+ expect(match.pattern, equals(glob));
+ });
+
+ test("returns the span of the string for start and end", () {
+ expect(match.start, equals(0));
+ expect(match.end, equals("foobar".length));
+ });
+
+ test("has a single group that contains the whole string", () {
+ expect(match.groupCount, equals(0));
+ expect(match[0], equals("foobar"));
+ expect(match.group(0), equals("foobar"));
+ expect(match.groups([0]), equals(["foobar"]));
+ });
+
+ test("throws a range error for an invalid group", () {
+ expect(() => match[1], throwsRangeError);
+ expect(() => match[-1], throwsRangeError);
+ expect(() => match.group(1), throwsRangeError);
+ expect(() => match.groups([1]), throwsRangeError);
+ });
+ });
+}
« no previous file with comments | « packages/glob/pubspec.yaml ('k') | packages/glob/test/list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698