Chromium Code Reviews| Index: pkg/args/test/utils.dart |
| diff --git a/pkg/args/test/utils.dart b/pkg/args/test/utils.dart |
| index 4586f573b0d12809f4f035eb4e65ea6daef9e933..a9b68efa15f936e857fac45b3b4fe3d9ad6441b0 100644 |
| --- a/pkg/args/test/utils.dart |
| +++ b/pkg/args/test/utils.dart |
| @@ -4,9 +4,67 @@ |
| library utils; |
| +import 'dart:async'; |
| + |
| import 'package:unittest/unittest.dart'; |
| import 'package:args/args.dart'; |
| +class FooCommand extends Command { |
| + var hasRun = false; |
| + |
| + final name = "foo"; |
| + final description = "Set a value."; |
| + final takesArguments = false; |
| + |
| + FooCommand(); |
|
Bob Nystrom
2014/12/11 20:25:31
Are these constructors needed?
nweiz
2014/12/11 23:55:24
Nope, removed.
|
| + |
| + 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; |
| + |
| + HiddenCommand(); |
| + |
| + 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"]; |
| + |
| + AliasedCommand(); |
| + |
| + void run() { |
| + hasRun = true; |
| + } |
| +} |
| + |
| +class AsyncCommand extends Command { |
| + var hasRun = false; |
| + |
| + final name = "async"; |
| + final description = "Set a value asynchronously."; |
| + final takesArguments = false; |
| + |
| + AsyncCommand(); |
| + |
| + Future run() => new Future.value().then((_) => hasRun = true); |
| +} |
| + |
| void throwsIllegalArg(function, {String reason: null}) { |
| expect(function, throwsArgumentError, reason: reason); |
| } |
| @@ -14,3 +72,12 @@ void throwsIllegalArg(function, {String reason: null}) { |
| void throwsFormat(ArgParser parser, List<String> args) { |
| expect(() => parser.parse(args), throwsFormatException); |
| } |
| + |
| +Matcher throwsUsageError(message, usage) { |
| + return throwsA(predicate((error) { |
| + expect(error, new isInstanceOf<UsageError>()); |
| + expect(error.message, message); |
| + expect(error.usage, usage); |
| + return true; |
| + })); |
| +} |