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

Unified Diff: pkg/analyzer/test/src/summary/index_unit_test.dart

Issue 1772823002: Record IS_ANCESTOR_OF relations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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/analyzer/lib/src/summary/index_unit.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/summary/index_unit_test.dart
diff --git a/pkg/analyzer/test/src/summary/index_unit_test.dart b/pkg/analyzer/test/src/summary/index_unit_test.dart
index 38e0e44bcfa3c498a4172e446a4aec7b10e6df32..6794ae5e4b58f64c1d76ca2933fba30a7f6a9a84 100644
--- a/pkg/analyzer/test/src/summary/index_unit_test.dart
+++ b/pkg/analyzer/test/src/summary/index_unit_test.dart
@@ -139,6 +139,43 @@ int set s (_) {}
_assertDefinedName('V', IndexNameKind.topLevel, 'V = 42;');
}
+ void test_hasAncestor_ClassDeclaration() {
+ _indexTestUnit('''
+class A {}
+class B1 extends A {}
+class B2 implements A {}
+class C1 extends B1 {}
+class C2 extends B2 {}
+class C3 implements B1 {}
+class C4 implements B2 {}
+class M extends Object with A {}
+''');
+ ClassElement classElementA = findElement("A");
+ assertThat(classElementA)
+ ..isAncestorOf('B1 extends A')
+ ..isAncestorOf('B2 implements A')
+ ..isAncestorOf('C1 extends B1')
+ ..isAncestorOf('C2 extends B2')
+ ..isAncestorOf('C3 implements B1')
+ ..isAncestorOf('C4 implements B2')
+ ..isAncestorOf('M extends Object with A');
+ }
+
+ void test_hasAncestor_ClassTypeAlias() {
+ _indexTestUnit('''
+class A {}
+class B extends A {}
+class C1 = Object with A;
+class C2 = Object with B;
+''');
+ ClassElement classElementA = findElement('A');
+ ClassElement classElementB = findElement('B');
+ assertThat(classElementA)
+ ..isAncestorOf('C1 = Object with A')
+ ..isAncestorOf('C2 = Object with B');
+ assertThat(classElementB)..isAncestorOf('C2 = Object with B');
+ }
+
void test_isExtendedBy_ClassDeclaration() {
_indexTestUnit('''
class A {} // 1
@@ -898,6 +935,11 @@ class _ElementIndexAssert {
_ElementIndexAssert(this.test, this.element);
+ void isAncestorOf(String search, {int length}) {
+ test._assertHasRelation(element, IndexRelationKind.IS_ANCESTOR_OF,
+ test._expectedLocation(search, false, length: length));
+ }
+
void isExtendedAt(String search, bool isQualified, {int length}) {
test._assertHasRelation(element, IndexRelationKind.IS_EXTENDED_BY,
test._expectedLocation(search, isQualified, length: length));
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698