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

Unified Diff: packages/args/test/utils.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/args/test/usage_test.dart ('k') | packages/async/.gitignore » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/args/test/utils.dart
diff --git a/packages/args/test/utils.dart b/packages/args/test/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1cdd803ab3c263ef019d80344d239dc71f96d50e
--- /dev/null
+++ b/packages/args/test/utils.dart
@@ -0,0 +1,83 @@
+// Copyright (c) 2013, 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.
+
+library utils;
+
+import 'dart:async';
+
+import 'package:args/args.dart';
+import 'package:args/command_runner.dart';
+import 'package:test/test.dart';
+
+class CommandRunnerWithFooter extends CommandRunner {
+ final usageFooter = "Also, footer!";
+
+ CommandRunnerWithFooter(String executableName, String description)
+ : super(executableName, description);
+}
+
+class FooCommand extends Command {
+ var hasRun = false;
+
+ final name = "foo";
+ final description = "Set a value.";
+ final takesArguments = false;
+
+ void run() {
+ hasRun = true;
+ }
+}
+
+class HiddenCommand extends Command {
+ var hasRun = false;
+
+ final name = "hidden";
+ final description = "Set a value.";
+ final hidden = true;
+ final takesArguments = false;
+
+ void run() {
+ hasRun = true;
+ }
+}
+
+class AliasedCommand extends Command {
+ var hasRun = false;
+
+ final name = "aliased";
+ final description = "Set a value.";
+ final takesArguments = false;
+ final aliases = const ["alias", "als"];
+
+ void run() {
+ hasRun = true;
+ }
+}
+
+class AsyncCommand extends Command {
+ var hasRun = false;
+
+ final name = "async";
+ final description = "Set a value asynchronously.";
+ final takesArguments = false;
+
+ Future run() => new Future.value().then((_) => hasRun = true);
+}
+
+void throwsIllegalArg(function, {String reason: null}) {
+ expect(function, throwsArgumentError, reason: reason);
+}
+
+void throwsFormat(ArgParser parser, List<String> args) {
+ expect(() => parser.parse(args), throwsFormatException);
+}
+
+Matcher throwsUsageError(message, usage) {
+ return throwsA(predicate((error) {
+ expect(error, new isInstanceOf<UsageException>());
+ expect(error.message, message);
+ expect(error.usage, usage);
+ return true;
+ }));
+}
« no previous file with comments | « packages/args/test/usage_test.dart ('k') | packages/async/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698