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

Unified 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 outer group and made local variables. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/args/test/parse_all_test.dart
diff --git a/pkg/args/test/parse_all_test.dart b/pkg/args/test/parse_all_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a921046465786147256074fb58c14bd3cc17ec4e
--- /dev/null
+++ b/pkg/args/test/parse_all_test.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2013, 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 parse_all_test;
+
+import 'package:unittest/unittest.dart';
+import 'package:args/args.dart';
+
+main() {
+ group('ArgParser.parse() starting with a non-option', () {
+ test('followed by flag', () {
+ var parser = new ArgParser()..addFlag('flag');
+ var args = ['A', '--flag'];
+
+ var results = parser.parse(args);
+ expect(results['flag'], isFalse);
+ expect(results.rest, orderedEquals(args));
+ });
+
+ test('followed by option', () {
+ var parser = new ArgParser()..addOption('opt');
+ var args = ['A', '--opt'];
+
+ var results = parser.parse(args);
+ expect(results['opt'], isNull);
+ expect(results.rest, orderedEquals(args));
+ });
+
+ test('followed by option and value', () {
+ var parser = new ArgParser()..addOption('opt');
+ var args = ['A', '--opt', 'V'];
+
+ var results = parser.parse(args);
+ expect(results['opt'], isNull);
+ expect(results.rest, orderedEquals(args));
+ });
+
+ test('followed by unknown flag', () {
+ var parser = new ArgParser();
+ var args = ['A', '--xflag'];
+ var results = parser.parse(args);
+ expect(results.rest, orderedEquals(args));
+ });
+
+ test('followed by unknown option and value', () {
+ var parser = new ArgParser();
+ var args = ['A', '--xopt', 'V'];
+ var results = parser.parse(args);
+ expect(results.rest, orderedEquals(args));
+ });
+
+ test('followed by command', () {
+ var parser = new ArgParser()..addCommand('com');
+ var args = ['A', 'com'];
+
+ var results = parser.parse(args);
+ expect(results.command, isNull);
+ expect(results.rest, orderedEquals(args));
+ });
+ });
+}
« 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