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

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: Removed bad tests. 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;
14
15 setUp(() {
16 parser = new ArgParser();
17 args = <String>[];
18 });
19
20 /// Tests that parsing beginning with an argument turns everything following
21 /// into an argument.
22 group('unknown argument', () {
Bob Nystrom 2013/06/19 00:23:18 "Unknown" is confusing here. "non-option"? How ab
Andrei Mouravski 2013/06/19 19:50:56 Done.
23 // args: 'A --flag'
Bob Nystrom 2013/06/19 00:23:18 Remove this and just make the arg list a list lite
Andrei Mouravski 2013/06/19 19:50:56 Done.
24 test('followed by flag', () {
25 args.add('A');
26 parser.addFlag('flag');
27 args.add('--flag');
28
29 var results = parser.parse(args);
Bob Nystrom 2013/06/19 00:23:18 Just inline the args here: parser.parse(['A', '--
Andrei Mouravski 2013/06/19 19:50:56 I'd rather keep it as a var so I can check against
Bob Nystrom 2013/06/19 19:53:04 OK, well at least create it using a literal. The .
Andrei Mouravski 2013/06/19 20:00:35 I did. You're looking at the wrong patch. :]
30 expect(results['flag'], isFalse);
31 expect(results.rest, orderedEquals(args));
32 });
33
34 // args: 'A --opt'
35 test('followed by option', () {
36 args.add('A');
37 parser.addOption('opt');
38
39 args.add('--opt');
40
41 var results = parser.parse(args);
42 expect(results['opt'], isNull);
43 expect(results.rest, orderedEquals(args));
44 });
45
46 // args: 'A --opt V'
47 test('followed by option and value', () {
48 args.add('A');
49 parser.addOption('opt');
50 args.add('--opt');
51 args.add('V');
52
53 var results = parser.parse(args);
54 expect(results['opt'], isNull);
55 expect(results.rest, orderedEquals(args));
56 });
57
58 // args: 'A --xflag'
59 test('followed by unknown flag', () {
60 args.add('A');
61 args.add('--xflag');
62 var results = parser.parse(args);
63 expect(results.rest, orderedEquals(args));
64 });
65
66 // args: 'A --xopt V'
67 test('followed by unknown option and value', () {
68 args.add('A');
69 args.add('--xopt');
70 args.add('V');
71 var results = parser.parse(args);
72 expect(results.rest, orderedEquals(args));
73 });
74
75 // args: 'A com'
76 test('followed by command', () {
77 args.add('A');
78 parser.addCommand('com');
79 args.add('com');
80
81 var results = parser.parse(args);
82 expect(results.command, isNull);
83 expect(results.rest, orderedEquals(args));
84 });
Bob Nystrom 2013/06/19 00:23:18 I think you could accomplish as much by adding a t
Andrei Mouravski 2013/06/19 19:50:56 I still think it's valuable to be spartan because
Bob Nystrom 2013/06/19 19:53:04 I don't understand this. Why do you want to contra
Andrei Mouravski 2013/06/19 20:00:35 I'm not contrasting with the other tests. I'm sayi
85 });
86 });
87 }
88
89 expectThrows(ArgParser parser, List<String> args) =>
90 expect(() => parser.parse(args), throws);
Bob Nystrom 2013/06/19 00:23:18 Unused? Remove.
Andrei Mouravski 2013/06/19 19:50:56 Done.
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