Chromium Code Reviews| Index: pkg/analysis_services/test/completion/completion_computer_test.dart |
| diff --git a/pkg/analysis_services/test/completion/completion_computer_test.dart b/pkg/analysis_services/test/completion/completion_computer_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f3b7ba654299d573ce14329e9f7caaf36596f788 |
| --- /dev/null |
| +++ b/pkg/analysis_services/test/completion/completion_computer_test.dart |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2014, 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 test.services.completion.suggestion; |
| + |
| +import 'package:analysis_services/completion/completion_computer.dart'; |
| +import 'package:analysis_services/src/completion/top_level_computer.dart'; |
| +import 'package:analysis_testing/abstract_single_unit.dart'; |
| +import 'package:analysis_testing/reflective_tests.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +main() { |
| + groupSep = ' | '; |
| + runReflectiveTests(CompletionComputerTest); |
| +} |
| + |
| +@ReflectiveTestCase() |
| +class CompletionComputerTest extends AbstractSingleUnitTest { |
| + |
| + test_topLevel() { |
| + CompletionComputer.create(null).then((computers) { |
| + assertContainsType(computers, TopLevelComputer); |
| + expect(computers.length, equals(1)); |
|
scheglov
2014/07/30 22:44:24
expect(computers, hasLength(1));
danrubel
2014/07/31 16:07:24
Done.
|
| + }); |
| + } |
| + |
| + /// Assert that the list contains exactly one of the given type |
| + void assertContainsType(List computers, Type type) { |
| + int count = 0; |
| + computers.forEach((c) { |
| + if (c.runtimeType == type) { |
| + ++count; |
| + } |
| + }); |
| + var msg = new StringBuffer(); |
| + msg.writeln('Expected 1 $type, but found:'); |
| + computers.forEach((c) { |
| + msg.writeln(' ${c.runtimeType}'); |
| + }); |
| + 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
|
| + fail(msg.toString()); |
| + } |
| + } |
| +} |