| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:observatory/cli.dart'; | 7 import 'package:observatory/cli.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 class TestCommand extends Command { | 10 class TestCommand extends Command { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 cmd.runCommand('a 55').catchError(expectAsync((e) { | 197 cmd.runCommand('a 55').catchError(expectAsync((e) { |
| 198 expect(e, equals('ambiguous')); | 198 expect(e, equals('ambiguous')); |
| 199 out.clear(); | 199 out.clear(); |
| 200 cmd.runCommand('ankl 55').then(expectAsync((_) { | 200 cmd.runCommand('ankl 55').then(expectAsync((_) { |
| 201 expect(out.toString(), equals('executing ankle([55])\n')); | 201 expect(out.toString(), equals('executing ankle([55])\n')); |
| 202 })); | 202 })); |
| 203 })); | 203 })); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void testCommandRunAlias() { |
| 207 // Run a simple command. |
| 208 StringBuffer out = new StringBuffer(); |
| 209 var aliasCmd = new TestCommand(out, 'alpha', []); |
| 210 aliasCmd.alias = 'a'; |
| 211 RootCommand cmd = new RootCommand([aliasCmd, |
| 212 new TestCommand(out, 'ankle', [])]); |
| 213 |
| 214 cmd.runCommand('a 55').then(expectAsync((_) { |
| 215 expect(out.toString(), equals('executing alpha([55])\n')); |
| 216 })); |
| 217 } |
| 218 |
| 206 main() { | 219 main() { |
| 207 test('command completion test suite', testCommandComplete); | 220 test('command completion test suite', testCommandComplete); |
| 208 test('run a simple command', testCommandRunSimple); | 221 test('run a simple command', testCommandRunSimple); |
| 209 test('run a subcommand', testCommandRunSubcommand); | 222 test('run a subcommand', testCommandRunSubcommand); |
| 210 test('run a command which is not found', testCommandRunNotFound); | 223 test('run a command which is not found', testCommandRunNotFound); |
| 211 test('run a command which is ambiguous', testCommandRunAmbiguous); | 224 test('run a command which is ambiguous', testCommandRunAmbiguous); |
| 225 test('run a command using an alias', testCommandRunAlias); |
| 212 } | 226 } |
| 213 | 227 |
| OLD | NEW |