Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, 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 test.services.completion.suggestion; | |
| 6 | |
| 7 import 'package:analysis_services/completion/completion_computer.dart'; | |
| 8 import 'package:analysis_services/src/completion/top_level_computer.dart'; | |
| 9 import 'package:analysis_testing/abstract_single_unit.dart'; | |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | |
| 11 import 'package:unittest/unittest.dart'; | |
| 12 | |
| 13 main() { | |
| 14 groupSep = ' | '; | |
| 15 runReflectiveTests(CompletionComputerTest); | |
| 16 } | |
| 17 | |
| 18 @ReflectiveTestCase() | |
| 19 class CompletionComputerTest extends AbstractSingleUnitTest { | |
| 20 | |
| 21 test_topLevel() { | |
| 22 CompletionComputer.create(null).then((computers) { | |
| 23 assertContainsType(computers, TopLevelComputer); | |
| 24 expect(computers.length, equals(1)); | |
|
scheglov
2014/07/30 22:44:24
expect(computers, hasLength(1));
danrubel
2014/07/31 16:07:24
Done.
| |
| 25 }); | |
| 26 } | |
| 27 | |
| 28 /// Assert that the list contains exactly one of the given type | |
| 29 void assertContainsType(List computers, Type type) { | |
| 30 int count = 0; | |
| 31 computers.forEach((c) { | |
| 32 if (c.runtimeType == type) { | |
| 33 ++count; | |
| 34 } | |
| 35 }); | |
| 36 var msg = new StringBuffer(); | |
| 37 msg.writeln('Expected 1 $type, but found:'); | |
| 38 computers.forEach((c) { | |
| 39 msg.writeln(' ${c.runtimeType}'); | |
| 40 }); | |
| 41 if (count != 1) { | |
|
scheglov
2014/07/30 22:44:24
Move if (count == 1) return; before constructing t
danrubel
2014/07/31 16:07:24
Good point. Moved msg construction inside if block
| |
| 42 fail(msg.toString()); | |
| 43 } | |
| 44 } | |
| 45 } | |
| OLD | NEW |