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

Unified Diff: pkg/analysis_services/test/correction/fix_test.dart

Issue 426793002: Test for the 'importing a package library' fix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
« no previous file with comments | « pkg/analysis_services/lib/src/correction/fix.dart ('k') | pkg/analysis_testing/lib/abstract_context.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_services/test/correction/fix_test.dart
diff --git a/pkg/analysis_services/test/correction/fix_test.dart b/pkg/analysis_services/test/correction/fix_test.dart
index c15ee2968d56cabd3d85d1ff006f007c931cc503..052051d074dc3a23d1812d71d1cdc2a416562e8a 100644
--- a/pkg/analysis_services/test/correction/fix_test.dart
+++ b/pkg/analysis_services/test/correction/fix_test.dart
@@ -12,9 +12,13 @@ import 'package:analysis_services/correction/fix.dart';
import 'package:analysis_services/index/index.dart';
import 'package:analysis_services/index/local_memory_index.dart';
import 'package:analysis_services/src/search/search_engine.dart';
+import 'package:analysis_testing/abstract_context.dart';
import 'package:analysis_testing/abstract_single_unit.dart';
import 'package:analysis_testing/reflective_tests.dart';
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/generated/error.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:unittest/unittest.dart';
@@ -858,19 +862,33 @@ main() {
''');
}
- void test_importLibraryPrefix_withType() {
+ void test_importLibraryPackage_withType() {
+ provider.newFile('/packages/my_pkg/lib/my_lib.dart', '''
+library my_lib;
+class Test {}
+''');
+ {
+ Folder myPkgFolder = provider.getResource('/packages/my_pkg/lib');
+ UriResolver pkgResolver = new PackageMapUriResolver(provider, {
+ 'my_pkg': [myPkgFolder]
+ });
+ context.sourceFactory = new SourceFactory(
+ [AbstractContextTest.SDK_RESOLVER, resourceResolver, pkgResolver]);
+ }
+ // force 'my_pkg' resolution
+ addSource('/tmp/other.dart', "import 'package:my_pkg/my_lib.dart';");
+ // try to find a fix
_indexTestUnit('''
-import 'dart:async' as pref;
main() {
- pref.Stream s = null;
- Future f = null;
+ Test test = null;
}
''');
- assertHasFix(FixKind.IMPORT_LIBRARY_PREFIX, '''
-import 'dart:async' as pref;
+ performAllAnalysisTasks();
+ assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
+import 'package:my_pkg/my_lib.dart';
+
main() {
- pref.Stream s = null;
- pref.Future f = null;
+ Test test = null;
}
''');
}
@@ -892,6 +910,23 @@ main() {
''');
}
+ void test_importLibraryPrefix_withType() {
+ _indexTestUnit('''
+import 'dart:async' as pref;
+main() {
+ pref.Stream s = null;
+ Future f = null;
+}
+''');
+ assertHasFix(FixKind.IMPORT_LIBRARY_PREFIX, '''
+import 'dart:async' as pref;
+main() {
+ pref.Stream s = null;
+ pref.Future f = null;
+}
+''');
+ }
+
void test_importLibraryProject_withFunction() {
addSource('/lib.dart', '''
library lib;
@@ -912,29 +947,6 @@ main() {
''');
}
- void test_importLibraryPackage_withType() {
- // TODO(scheglov) move PackageMapUriResolver into analyzer and implement
- provider.newFile('/packages/my_pkg/lib/my_lib.dart', '''
-//library my_lib;
-//class Test {}
-//''');
-// testFile = '/project/test.dart';
-// addSource('/tmp/other.dart', "import 'package:my_pkg/my_lib.dart';");
-// _indexTestUnit('''
-//main() {
-// Test test = null;
-//}
-//''');
-// performAllAnalysisTasks();
-// assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
-//import 'package:my_pkg/my_lib.dart';
-//
-//main() {
-// Test test = null;
-//}
-//''');
- }
-
void test_importLibraryProject_withTopLevelVariable() {
addSource('/lib.dart', '''
library lib;
« no previous file with comments | « pkg/analysis_services/lib/src/correction/fix.dart ('k') | pkg/analysis_testing/lib/abstract_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698