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

Unified Diff: packages/glob/test/parse_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/test/match_test.dart ('k') | packages/html/.gitignore » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/glob/test/parse_test.dart
diff --git a/packages/glob/test/parse_test.dart b/packages/glob/test/parse_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..77dba9574308024ef1baf6241fb51c32085a0def
--- /dev/null
+++ b/packages/glob/test/parse_test.dart
@@ -0,0 +1,96 @@
+// 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:path/path.dart' as p;
+import 'package:test/test.dart';
+
+void main() {
+ test("supports backslash-escaped characters", () {
+ expect(r"*[]{,}?()", contains(new Glob(r"\*\[\]\{\,\}\?\(\)")));
+ if (p.style != p.Style.windows) {
+ expect(r"foo\bar", contains(new Glob(r"foo\\bar")));
+ }
+ });
+
+ test("disallows an empty glob", () {
+ expect(() => new Glob(""), throwsFormatException);
+ });
+
+ group("range", () {
+ test("supports either ^ or ! for negated ranges", () {
+ var bang = new Glob("fo[!a-z]");
+ expect("foo", isNot(contains(bang)));
+ expect("fo2", contains(bang));
+
+ var caret = new Glob("fo[^a-z]");
+ expect("foo", isNot(contains(caret)));
+ expect("fo2", contains(caret));
+ });
+
+ test("supports backslash-escaped characters", () {
+ var glob = new Glob(r"fo[\*\--\]]");
+ expect("fo]", contains(glob));
+ expect("fo-", contains(glob));
+ expect("fo*", contains(glob));
+ });
+
+ test("disallows inverted ranges", () {
+ expect(() => new Glob(r"[z-a]"), throwsFormatException);
+ });
+
+ test("disallows empty ranges", () {
+ expect(() => new Glob(r"[]"), throwsFormatException);
+ });
+
+ test("disallows unclosed ranges", () {
+ expect(() => new Glob(r"[abc"), throwsFormatException);
+ expect(() => new Glob(r"[-"), throwsFormatException);
+ });
+
+ test("disallows dangling ]", () {
+ expect(() => new Glob(r"abc]"), throwsFormatException);
+ });
+
+ test("disallows explicit /", () {
+ expect(() => new Glob(r"[/]"), throwsFormatException);
+ expect(() => new Glob(r"[ -/]"), throwsFormatException);
+ expect(() => new Glob(r"[/-~]"), throwsFormatException);
+ });
+ });
+
+ group("options", () {
+ test("allows empty branches", () {
+ var glob = new Glob("foo{,bar}");
+ expect("foo", contains(glob));
+ expect("foobar", contains(glob));
+ });
+
+ test("disallows empty options", () {
+ expect(() => new Glob("{}"), throwsFormatException);
+ });
+
+ test("disallows single options", () {
+ expect(() => new Glob("{foo}"), throwsFormatException);
+ });
+
+ test("disallows unclosed options", () {
+ expect(() => new Glob("{foo,bar"), throwsFormatException);
+ expect(() => new Glob("{foo,"), throwsFormatException);
+ });
+
+ test("disallows dangling }", () {
+ expect(() => new Glob("foo}"), throwsFormatException);
+ });
+
+ test("disallows dangling ] in options", () {
+ expect(() => new Glob(r"{abc]}"), throwsFormatException);
+ });
+ });
+
+ test("disallows unescaped parens", () {
+ expect(() => new Glob("foo(bar"), throwsFormatException);
+ expect(() => new Glob("foo)bar"), throwsFormatException);
+ });
+}
« no previous file with comments | « packages/glob/test/match_test.dart ('k') | packages/html/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698