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

Unified Diff: pkg/analyzer/test/generated/element_test.dart

Issue 1007563003: fix for getting node for class element (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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/generated/element.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/generated/element_test.dart
===================================================================
--- pkg/analyzer/test/generated/element_test.dart (revision 44535)
+++ pkg/analyzer/test/generated/element_test.dart (working copy)
@@ -858,7 +858,7 @@
expect(classA.lookUpSetter("s", library), isNull);
}
- void test_node() {
+ void test_node_ClassDeclaration() {
AnalysisContextHelper contextHelper = new AnalysisContextHelper();
AnalysisContext context = contextHelper.context;
Source source = contextHelper.addSource("/test.dart", r'''
@@ -893,9 +893,27 @@
expect(nodeC.element, same(elementC));
}
}
+
+ void test_node_ClassTypeAlias() {
+ AnalysisContextHelper contextHelper = new AnalysisContextHelper();
+ AnalysisContext context = contextHelper.context;
+ Source source = contextHelper.addSource("/test.dart", r'''
+abstract class A<K, V> = Object with MapMixin<K, V>;
+''');
+ // prepare CompilationUnitElement
+ LibraryElement libraryElement = context.computeLibraryElement(source);
+ CompilationUnitElement unitElement = libraryElement.definingCompilationUnit;
+ // A
+ {
+ ClassElement elementA = unitElement.getType("A");
+ ClassTypeAlias nodeA = elementA.node;
+ expect(nodeA, isNotNull);
+ expect(nodeA.name.name, "A");
+ expect(nodeA.element, same(elementA));
+ }
+ }
}
-
@reflectiveTest
class CompilationUnitElementImplTest extends EngineTestCase {
void test_getEnum_declared() {
@@ -1261,12 +1279,12 @@
void test_isSubtypeOf_namedParameters_isNotAssignable() {
// ! ({name: A}) -> void <: ({name: B}) -> void
- FunctionType t = ElementFactory.functionElement4("t", null, null, <String>[
- "name"
- ], <ClassElement>[ElementFactory.classElement2("A")]).type;
- FunctionType s = ElementFactory.functionElement4("s", null, null, <String>[
- "name"
- ], <ClassElement>[ElementFactory.classElement2("B")]).type;
+ FunctionType t = ElementFactory.functionElement4("t", null, null,
+ <String>["name"],
+ <ClassElement>[ElementFactory.classElement2("A")]).type;
+ FunctionType s = ElementFactory.functionElement4("s", null, null,
+ <String>["name"],
+ <ClassElement>[ElementFactory.classElement2("B")]).type;
expect(t.isSubtypeOf(s), isFalse);
}
@@ -3469,12 +3487,10 @@
AnalysisContext context = createAnalysisContext();
LibraryElementImpl library = ElementFactory.library(context, "app");
LibraryElementImpl libraryA = ElementFactory.library(context, "A");
- libraryA.imports = <ImportElementImpl>[
- ElementFactory.importFor(library, null)
- ];
- library.imports = <ImportElementImpl>[
- ElementFactory.importFor(libraryA, null)
- ];
+ libraryA.imports =
+ <ImportElementImpl>[ElementFactory.importFor(library, null)];
+ library.imports =
+ <ImportElementImpl>[ElementFactory.importFor(libraryA, null)];
List<LibraryElement> libraries = library.visibleLibraries;
expect(libraries, unorderedEquals(<LibraryElement>[library, libraryA]));
}
@@ -3492,9 +3508,8 @@
AnalysisContext context = createAnalysisContext();
LibraryElementImpl library = ElementFactory.library(context, "app");
LibraryElementImpl libraryA = ElementFactory.library(context, "A");
- library.imports = <ImportElementImpl>[
- ElementFactory.importFor(libraryA, null)
- ];
+ library.imports =
+ <ImportElementImpl>[ElementFactory.importFor(libraryA, null)];
List<LibraryElement> libraries = library.visibleLibraries;
expect(libraries, unorderedEquals(<LibraryElement>[library, libraryA]));
}
@@ -3505,9 +3520,8 @@
LibraryElementImpl libraryA = ElementFactory.library(context, "A");
LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
libraryA.exports = <ExportElementImpl>[ElementFactory.exportFor(libraryAA)];
- library.imports = <ImportElementImpl>[
- ElementFactory.importFor(libraryA, null)
- ];
+ library.imports =
+ <ImportElementImpl>[ElementFactory.importFor(libraryA, null)];
List<LibraryElement> libraries = library.visibleLibraries;
expect(libraries,
unorderedEquals(<LibraryElement>[library, libraryA, libraryAA]));
@@ -3519,9 +3533,8 @@
LibraryElementImpl libraryA = ElementFactory.library(context, "A");
LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
LibraryElementImpl libraryB = ElementFactory.library(context, "B");
- libraryA.imports = <ImportElementImpl>[
- ElementFactory.importFor(libraryAA, null)
- ];
+ libraryA.imports =
+ <ImportElementImpl>[ElementFactory.importFor(libraryAA, null)];
library.imports = <ImportElementImpl>[
ElementFactory.importFor(libraryA, null),
ElementFactory.importFor(libraryB, null)
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698