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

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

Issue 2539263002: Fix for constructor search. (Closed)
Patch Set: Created 4 years 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/analyzer/lib/src/dart/analysis/search.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/analysis/search_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index cc81172b3059d727e63f928e4b7e2e0656356fbb..ea63eebd4a9f04e80cb665a316511d88494a6496 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -141,7 +141,52 @@ part 'my_part.dart';
await _verifyReferences(element, expected);
}
- test_searchReferences_ConstructorElement() async {
+ test_searchReferences_ConstructorElement_default() async {
+ await _resolveTestUnit('''
+class A {
+ A() {}
+}
+main() {
+ new A();
+}
+''');
+ ConstructorElement element = _findElementAtString('A() {}');
+ Element mainElement = _findElement('main');
+ var expected = [
+ _expectIdQ(mainElement, SearchResultKind.REFERENCE, '();', length: 0)
+ ];
+ await _verifyReferences(element, expected);
+ }
+
+ test_searchReferences_ConstructorElement_default_otherFile() async {
+ String other = _p('$testProject/other.dart');
Paul Berry 2016/12/01 13:18:03 This test fails on Windows. See https://build.chr
+ String otherCode = '''
+import 'test.dart';
+main() {
+ new A(); // in other
+}
+''';
+ provider.newFile(other, otherCode);
+ driver.addFile(other);
+
+ await _resolveTestUnit('''
+class A {
+ A() {}
+}
+''');
+ ConstructorElement element = _findElementAtString('A() {}');
+
+ CompilationUnit otherUnit = (await driver.getResult(other)).unit;
+ Element main = otherUnit.element.functions[0];
+ var expected = [
+ new ExpectedResult(main, SearchResultKind.REFERENCE,
+ otherCode.indexOf('(); // in other'), 0,
+ isResolved: true, isQualified: true)
+ ];
+ await _verifyReferences(element, expected);
+ }
+
+ test_searchReferences_ConstructorElement_named() async {
await _resolveTestUnit('''
class A {
A.named() {}
@@ -154,7 +199,7 @@ main() {
Element mainElement = _findElement('main');
var expected = [
_expectIdQ(mainElement, SearchResultKind.REFERENCE, '.named();',
- length: 6)
+ length: '.named'.length)
];
await _verifyReferences(element, expected);
}
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/search.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698