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

Side by Side Diff: pkg/args/test/parse_all_test.dart

Issue 17333004: Added new style of tests for parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library parse_all_test;
6
7 import 'package:unittest/unittest.dart';
8 import 'package:args/args.dart';
9
10 main() {
11 group('ArgParser.parse()', () {
12 var parser;
13 var args;
Bob Nystrom 2013/06/19 22:22:21 How about removing these and just making them loca
Andrei Mouravski 2013/06/19 23:16:20 Done.
14
15 setUp(() {
16 parser = new ArgParser();
17 args = <String>[];
18 });
19
20 group('starting with a non-option', () {
21 test('followed by flag', () {
22 parser.addFlag('flag');
23 args = ['A', '--flag'];
24
25 var results = parser.parse(args);
26 expect(results['flag'], isFalse);
27 expect(results.rest, orderedEquals(args));
28 });
29
30 test('followed by option', () {
31 parser.addOption('opt');
32 args = ['A', '--opt'];
33
34 var results = parser.parse(args);
35 expect(results['opt'], isNull);
36 expect(results.rest, orderedEquals(args));
37 });
38
39 test('followed by option and value', () {
40 parser.addOption('opt');
41 args = ['A', '--opt', 'V'];
42
43 var results = parser.parse(args);
44 expect(results['opt'], isNull);
45 expect(results.rest, orderedEquals(args));
46 });
47
48 test('followed by unknown flag', () {
49 args = ['A', '--xflag'];
50 var results = parser.parse(args);
51 expect(results.rest, orderedEquals(args));
52 });
53
54 test('followed by unknown option and value', () {
55 args = ['A', '--xopt', 'V'];
56 var results = parser.parse(args);
57 expect(results.rest, orderedEquals(args));
58 });
59
60 test('followed by command', () {
61 parser.addCommand('com');
62 args = ['A', 'com'];
63
64 var results = parser.parse(args);
65 expect(results.command, isNull);
66 expect(results.rest, orderedEquals(args));
67 });
68 });
69 });
70 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698