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

Unified Diff: pkg/analyzer/test/src/dart/element/element_test.dart

Issue 2314963002: Remove the final error being generated in a scope (Closed)
Patch Set: Created 4 years, 3 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/test/generated/static_type_analyzer_test.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/element/element_test.dart
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index ed56338690202cec556e34660099775f97834e1e..72aae14578732b48d25646fa119ed00de3dde31d 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -4076,8 +4076,11 @@ abstract class A {
@reflectiveTest
class MultiplyDefinedElementImplTest extends EngineTestCase {
void test_fromElements_conflicting() {
- Element firstElement = ElementFactory.localVariableElement2("xx");
- Element secondElement = ElementFactory.localVariableElement2("yy");
+ TopLevelVariableElement firstElement =
+ ElementFactory.topLevelVariableElement2('xx');
+ TopLevelVariableElement secondElement =
+ ElementFactory.topLevelVariableElement2('yy');
+ _addToLibrary([firstElement, secondElement]);
Element result = MultiplyDefinedElementImpl.fromElements(
null, firstElement, secondElement);
EngineTestCase.assertInstanceOf(
@@ -4086,15 +4089,19 @@ class MultiplyDefinedElementImplTest extends EngineTestCase {
(result as MultiplyDefinedElement).conflictingElements;
expect(elements, hasLength(2));
for (int i = 0; i < elements.length; i++) {
- EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement,
- LocalVariableElement, elements[i]);
+ EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement,
+ TopLevelVariableElement, elements[i]);
}
}
void test_fromElements_multiple() {
- Element firstElement = ElementFactory.localVariableElement2("xx");
- Element secondElement = ElementFactory.localVariableElement2("yy");
- Element thirdElement = ElementFactory.localVariableElement2("zz");
+ TopLevelVariableElement firstElement =
+ ElementFactory.topLevelVariableElement2('xx');
+ TopLevelVariableElement secondElement =
+ ElementFactory.topLevelVariableElement2('yy');
+ TopLevelVariableElement thirdElement =
+ ElementFactory.topLevelVariableElement2('zz');
+ _addToLibrary([firstElement, secondElement, thirdElement]);
Element result = MultiplyDefinedElementImpl.fromElements(
null,
MultiplyDefinedElementImpl.fromElements(
@@ -4106,16 +4113,26 @@ class MultiplyDefinedElementImplTest extends EngineTestCase {
(result as MultiplyDefinedElement).conflictingElements;
expect(elements, hasLength(3));
for (int i = 0; i < elements.length; i++) {
- EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement,
- LocalVariableElement, elements[i]);
+ EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement,
+ TopLevelVariableElement, elements[i]);
}
}
void test_fromElements_nonConflicting() {
- Element element = ElementFactory.localVariableElement2("xx");
+ TopLevelVariableElement element =
+ ElementFactory.topLevelVariableElement2('xx');
+ _addToLibrary([element]);
expect(MultiplyDefinedElementImpl.fromElements(null, element, element),
same(element));
}
+
+ void _addToLibrary(List<TopLevelVariableElement> variables) {
+ CompilationUnitElementImpl compilationUnit =
+ ElementFactory.compilationUnit('lib.dart');
+ LibraryElementImpl library = ElementFactory.library(null, 'lib');
+ library.definingCompilationUnit = compilationUnit;
+ compilationUnit.topLevelVariables = variables;
+ }
}
@reflectiveTest
« no previous file with comments | « pkg/analyzer/test/generated/static_type_analyzer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698