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

Unified Diff: pkg/args/test/args_test.dart

Issue 88553003: pkg/args: a bunch of test cleanup (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nits Created 7 years, 1 month 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/args/test/command_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/args/test/args_test.dart
diff --git a/pkg/args/test/args_test.dart b/pkg/args/test/args_test.dart
index cf31cc26210fba5cca1a4e8646db401a6e3129d1..075a3e83351cd620d1e7549e92535090b8a7b0f9 100644
--- a/pkg/args/test/args_test.dart
+++ b/pkg/args/test/args_test.dart
@@ -6,8 +6,9 @@ library args_test;
import 'package:unittest/unittest.dart';
import 'package:args/args.dart';
+import 'utils.dart';
-main() {
+void main() {
group('ArgParser.addFlag()', () {
test('throws ArgumentError if the flag already exists', () {
var parser = new ArgParser();
@@ -182,43 +183,40 @@ main() {
});
});
- group('ArgResults.options', () {
- test('returns the provided options', () {
- var parser = new ArgParser();
- parser.addFlag('woof');
- parser.addOption('meow');
- var args = parser.parse(['--woof', '--meow', 'kitty']);
- expect(args.options, hasLength(2));
- expect(args.options.any((o) => o == 'woof'), isTrue);
- expect(args.options.any((o) => o == 'meow'), isTrue);
- });
-
- test('includes defaulted options', () {
- var parser = new ArgParser();
- parser.addFlag('woof', defaultsTo: false);
- parser.addOption('meow', defaultsTo: 'kitty');
- var args = parser.parse([]);
- expect(args.options, hasLength(2));
- expect(args.options.any((o) => o == 'woof'), isTrue);
- expect(args.options.any((o) => o == 'meow'), isTrue);
- });
- });
-
- group('ArgResults[]', () {
- test('throws if the name is not an option', () {
+ group('ArgResults', () {
+ group('options', () {
+ test('returns the provided options', () {
+ var parser = new ArgParser();
+ parser.addFlag('woof');
+ parser.addOption('meow');
+ var args = parser.parse(['--woof', '--meow', 'kitty']);
+ expect(args.options, hasLength(2));
+ expect(args.options, contains('woof'));
+ expect(args.options, contains('meow'));
+ });
+
+ test('includes defaulted options', () {
+ var parser = new ArgParser();
+ parser.addFlag('woof', defaultsTo: false);
+ parser.addOption('meow', defaultsTo: 'kitty');
+ var args = parser.parse([]);
+ expect(args.options, hasLength(2));
+ expect(args.options, contains('woof'));
+ expect(args.options, contains('meow'));
+ });
+ });
+
+ test('[] throws if the name is not an option', () {
var parser = new ArgParser();
var results = parser.parse([]);
throwsIllegalArg(() => results['unknown']);
});
- });
-}
-
-throwsIllegalArg(function, {String reason: null}) {
- expect(function, throwsArgumentError, reason: reason);
-}
-throwsFormat(ArgParser parser, List<String> args) {
- expect(() => parser.parse(args), throwsFormatException);
+ test('rest cannot be modified', () {
+ var results = new ArgResults({}, '', null, []);
+ expect(() => results.rest.add('oops'), throwsUnsupportedError);
+ });
+ });
}
const _INVALID_OPTIONS = const [
« no previous file with comments | « no previous file | pkg/args/test/command_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698