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

Unified Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2526373002: Add AnalysisDriver.getIndex(). (Closed)
Patch Set: Created 4 years, 1 month 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/analyzer/test/src/dart/analysis/driver_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 1fd629ba574b24cf2b5b2a64f49a0f37ae1bc938..6b4231e490ec7c327ce4c1ba063430e9e270cf38 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -379,27 +379,6 @@ var A2 = B1;
}
}
- test_getResult() async {
- String content = 'int f() => 42;';
- addTestFile(content, priority: true);
-
- AnalysisResult result = await driver.getResult(testFile);
- expect(result.path, testFile);
- expect(result.uri.toString(), 'package:test/test.dart');
- expect(result.content, content);
- expect(result.contentHash, _md5(content));
- expect(result.unit, isNotNull);
- expect(result.errors, hasLength(0));
-
- var f = result.unit.declarations[0] as FunctionDeclaration;
- expect(f.name.staticType.toString(), '() → int');
- expect(f.returnType.type.toString(), 'int');
-
- // The same result is also received through the stream.
- await _waitForIdle();
- expect(allResults, [result]);
- }
-
test_getFilesReferencingName() async {
var a = _p('/test/bin/a.dart');
var b = _p('/test/bin/b.dart');
@@ -431,6 +410,51 @@ var A2 = B1;
expect(files2, unorderedEquals([b, c]));
}
+ test_getIndex() async {
+ String content = r'''
+foo(int p) {}
+main() {
+ foo(42);
+}
+''';
+ addTestFile(content);
+
+ IndexResult result = await driver.getIndex(testFile);
+
+ CompilationUnitElement unitElement = result.unitElement;
+ expect(unitElement, isNotNull);
+ expect(unitElement.source.fullName, testFile);
+ expect(unitElement.functions.map((c) => c.name),
+ unorderedEquals(['foo', 'main']));
+
+ AnalysisDriverUnitIndex index = result.index;
+ int unitId = index.strings.indexOf('package:test/test.dart');
+ int fooId = index.strings.indexOf('foo');
+ expect(unitId, isNonNegative);
+ expect(fooId, isNonNegative);
+ }
+
+ test_getResult() async {
+ String content = 'int f() => 42;';
+ addTestFile(content, priority: true);
+
+ AnalysisResult result = await driver.getResult(testFile);
+ expect(result.path, testFile);
+ expect(result.uri.toString(), 'package:test/test.dart');
+ expect(result.content, content);
+ expect(result.contentHash, _md5(content));
+ expect(result.unit, isNotNull);
+ expect(result.errors, hasLength(0));
+
+ var f = result.unit.declarations[0] as FunctionDeclaration;
+ expect(f.name.staticType.toString(), '() → int');
+ expect(f.returnType.type.toString(), 'int');
+
+ // The same result is also received through the stream.
+ await _waitForIdle();
+ expect(allResults, [result]);
+ }
+
test_getResult_constants_defaultParameterValue_localFunction() async {
var a = _p('/test/bin/a.dart');
var b = _p('/test/bin/b.dart');
@@ -469,24 +493,6 @@ main() {
}
}
- test_getResult_hasIndex() async {
- String content = r'''
-foo(int p) {}
-main() {
- foo(42);
-}
-''';
- addTestFile(content);
-
- AnalysisResult result = await driver.getResult(testFile);
-
- AnalysisDriverUnitIndex index = result.index;
- int unitId = index.strings.indexOf('package:test/test.dart');
- int fooId = index.strings.indexOf('foo');
- expect(unitId, isNonNegative);
- expect(fooId, isNonNegative);
- }
-
test_getResult_inferTypes_finalField() async {
addTestFile(
r'''
@@ -1118,7 +1124,6 @@ var A = B;
expect(result.contentHash, _md5(content));
expect(result.unit, isNull);
expect(result.errors, hasLength(0));
- expect(result.index, isNotNull);
}
test_results_status() async {

Powered by Google App Engine
This is Rietveld 408576698