| 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, hasLength(1)); |
| 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 if (count != 1) { |
| 37 var msg = new StringBuffer(); |
| 38 msg.writeln('Expected $type, but found:'); |
| 39 computers.forEach((c) { |
| 40 msg.writeln(' ${c.runtimeType}'); |
| 41 }); |
| 42 fail(msg.toString()); |
| 43 } |
| 44 } |
| 45 } |
| OLD | NEW |