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

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

Issue 814113004: Pull args, intl, logging, shelf, and source_maps out of the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also csslib. Created 6 years 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 | « pkg/args/test/args_test.dart ('k') | pkg/args/test/command_runner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/args/test/command_parse_test.dart
diff --git a/pkg/args/test/command_parse_test.dart b/pkg/args/test/command_parse_test.dart
deleted file mode 100644
index ac530564b29b93fb945b131f08b9fb6ec40bf945..0000000000000000000000000000000000000000
--- a/pkg/args/test/command_parse_test.dart
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright (c) 2012, 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 command_parse_test;
-
-import 'package:unittest/unittest.dart';
-import 'package:args/args.dart';
-import 'utils.dart';
-
-void main() {
- group('ArgParser.addCommand()', () {
- test('creates a new ArgParser if none is given', () {
- var parser = new ArgParser();
- var command = parser.addCommand('install');
- expect(parser.commands['install'], equals(command));
- expect(command is ArgParser, isTrue);
- });
-
- test('uses the command parser if given one', () {
- var parser = new ArgParser();
- var command = new ArgParser();
- var result = parser.addCommand('install', command);
- expect(parser.commands['install'], equals(command));
- expect(result, equals(command));
- });
-
- test('throws on a duplicate command name', () {
- var parser = new ArgParser();
- parser.addCommand('install');
- throwsIllegalArg(() => parser.addCommand('install'));
- });
- });
-
- group('ArgParser.parse()', () {
- test('parses a command', () {
- var parser = new ArgParser();
- var command = parser.addCommand('install');
-
- var args = parser.parse(['install']);
-
- expect(args.command.name, equals('install'));
- expect(args.rest, isEmpty);
- });
-
- test('parses a command option', () {
- var parser = new ArgParser();
- var command = parser.addCommand('install');
- command.addOption('path');
-
- var args = parser.parse(['install', '--path', 'some/path']);
- expect(args.command['path'], equals('some/path'));
- });
-
- test('parses a parent solo option before the command', () {
- var parser = new ArgParser();
- parser.addOption('mode', abbr: 'm');
- var command = parser.addCommand('install');
-
- var args = parser.parse(['-m', 'debug', 'install']);
- expect(args['mode'], equals('debug'));
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent solo option after the command', () {
- var parser = new ArgParser();
- parser.addOption('mode', abbr: 'm');
- var command = parser.addCommand('install');
-
- var args = parser.parse(['install', '-m', 'debug']);
- expect(args['mode'], equals('debug'));
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent option before the command', () {
- var parser = new ArgParser();
- parser.addFlag('verbose');
- var command = parser.addCommand('install');
-
- var args = parser.parse(['--verbose', 'install']);
- expect(args['verbose'], isTrue);
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent option after the command', () {
- var parser = new ArgParser();
- parser.addFlag('verbose');
- var command = parser.addCommand('install');
-
- var args = parser.parse(['install', '--verbose']);
- expect(args['verbose'], isTrue);
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent negated option before the command', () {
- var parser = new ArgParser();
- parser.addFlag('verbose', defaultsTo: true);
- var command = parser.addCommand('install');
-
- var args = parser.parse(['--no-verbose', 'install']);
- expect(args['verbose'], isFalse);
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent negated option after the command', () {
- var parser = new ArgParser();
- parser.addFlag('verbose', defaultsTo: true);
- var command = parser.addCommand('install');
-
- var args = parser.parse(['install', '--no-verbose']);
- expect(args['verbose'], isFalse);
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent abbreviation before the command', () {
- var parser = new ArgParser();
- parser.addFlag('debug', abbr: 'd');
- parser.addFlag('verbose', abbr: 'v');
- var command = parser.addCommand('install');
-
- var args = parser.parse(['-dv', 'install']);
- expect(args['debug'], isTrue);
- expect(args['verbose'], isTrue);
- expect(args.command.name, equals('install'));
- });
-
- test('parses a parent abbreviation after the command', () {
- var parser = new ArgParser();
- parser.addFlag('debug', abbr: 'd');
- parser.addFlag('verbose', abbr: 'v');
- var command = parser.addCommand('install');
-
- var args = parser.parse(['install', '-dv']);
- expect(args['debug'], isTrue);
- expect(args['verbose'], isTrue);
- expect(args.command.name, equals('install'));
- });
-
- test('does not parse a solo command option before the command', () {
- var parser = new ArgParser();
- var command = parser.addCommand('install');
- command.addOption('path', abbr: 'p');
-
- throwsFormat(parser, ['-p', 'foo', 'install']);
- });
-
- test('does not parse a command option before the command', () {
- var parser = new ArgParser();
- var command = parser.addCommand('install');
- command.addOption('path');
-
- throwsFormat(parser, ['--path', 'foo', 'install']);
- });
-
- test('does not parse a command abbreviation before the command', () {
- var parser = new ArgParser();
- var command = parser.addCommand('install');
- command.addFlag('debug', abbr: 'd');
- command.addFlag('verbose', abbr: 'v');
-
- throwsFormat(parser, ['-dv', 'install']);
- });
-
- test('assigns collapsed options to the proper command', () {
- var parser = new ArgParser();
- parser.addFlag('apple', abbr: 'a');
- var command = parser.addCommand('cmd');
- command.addFlag('banana', abbr: 'b');
- var subcommand = command.addCommand('subcmd');
- subcommand.addFlag('cherry', abbr: 'c');
-
- var args = parser.parse(['cmd', 'subcmd', '-abc']);
- expect(args['apple'], isTrue);
- expect(args.command.name, equals('cmd'));
- expect(args.command['banana'], isTrue);
- expect(args.command.command.name, equals('subcmd'));
- expect(args.command.command['cherry'], isTrue);
- });
-
- test('option is given to innermost command that can take it', () {
- var parser = new ArgParser();
- parser.addFlag('verbose');
- var command = parser.addCommand('cmd');
- command.addFlag('verbose');
- var subcommand = command.addCommand('subcmd');
-
- var args = parser.parse(['cmd', 'subcmd', '--verbose']);
- expect(args['verbose'], isFalse);
- expect(args.command.name, equals('cmd'));
- expect(args.command['verbose'], isTrue);
- expect(args.command.command.name, equals('subcmd'));
- });
-
- test('remaining arguments are given to the innermost command', () {
- var parser = new ArgParser();
- var command = parser.addCommand('cmd');
- var subcommand = command.addCommand('subcmd');
-
- var args = parser.parse(['cmd', 'subcmd', 'other', 'stuff']);
- expect(args.command.name, equals('cmd'));
- expect(args.rest, isEmpty);
- expect(args.command.command.name, equals('subcmd'));
- expect(args.command.rest, isEmpty);
- expect(args.command.command.rest, equals(['other', 'stuff']));
- });
- });
-}
« no previous file with comments | « pkg/args/test/args_test.dart ('k') | pkg/args/test/command_runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698