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

Unified Diff: pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart

Issue 3002643002: Fix insertion of imports when there are no existing directives (issue 30430) (Closed)
Patch Set: Created 3 years, 4 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
Index: pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
index 825d8d36356d461bf4ed2c39db5e2536afa862b6..23462db61e2d0d5514d7732b09cfc6440543f392 100644
--- a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -132,6 +132,25 @@ blankLine() {
expect(elements.elements, unorderedEquals(['String']));
}
+ test_dartMath_noPrefix() async {
+ String selection = "new Random();";
+ String content = """
+import 'dart:math';
+bool randomBool() {
+ Random r = $selection
+ return r.nextBool();
+}
+""";
+ List<ImportedElements> elementsList = await _computeElements(
+ content, content.indexOf(selection), selection.length);
+ expect(elementsList, hasLength(1));
+ ImportedElements elements = elementsList[0];
+ expect(elements, isNotNull);
+ expect(elements.path, '/lib/math/math.dart');
+ expect(elements.prefix, '');
+ expect(elements.elements, unorderedEquals(['Random']));
+ }
+
test_none_comment() async {
String selection = 'comment';
String content = """

Powered by Google App Engine
This is Rietveld 408576698