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

Unified Diff: pkg/analyzer/test/src/task/incremental_element_builder_test.dart

Issue 1204423002: Test for final top-level variables. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/task/incremental_element_builder.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/task/incremental_element_builder_test.dart
diff --git a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
index 415e03157661946fecd4202f5601d2bfd165936d..cc6e95b6b0d9032750bf61fd5e6977a3085b3f32 100644
--- a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
+++ b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
@@ -543,6 +543,54 @@ typedef B();
expect(unitDelta.removedDeclarations, unorderedEquals([]));
}
+ test_unitMembers_topLevelVariable() {
+ _buildOldUnit(r'''
+bool a = 1, b = 2;
+int c = 3;
+''');
+ List<CompilationUnitMember> oldNodes = oldUnit.declarations.toList();
+ _buildNewUnit(r'''
+int c = 3;
+
+bool a =1, b = 2;
+''');
+ List<CompilationUnitMember> newNodes = newUnit.declarations;
+ {
+ TopLevelVariableDeclaration newNode = newNodes[0];
+ expect(newNode, same(oldNodes[1]));
+ expect(getNodeText(newNode), 'int c = 3;');
+ {
+ TopLevelVariableElement element =
+ newNode.variables.variables[0].element;
+ expect(element, isNotNull);
+ expect(element.name, 'c');
+ expect(element.nameOffset, newCode.indexOf('c = 3'));
+ }
+ }
+ {
+ TopLevelVariableDeclaration newNode = newNodes[1];
+ expect(newNode, same(oldNodes[0]));
+ expect(getNodeText(newNode), 'bool a =1, b = 2;');
+ {
+ TopLevelVariableElement element =
+ newNode.variables.variables[0].element;
+ expect(element, isNotNull);
+ expect(element.name, 'a');
+ expect(element.nameOffset, newCode.indexOf('a =1'));
+ }
+ {
+ TopLevelVariableElement element =
+ newNode.variables.variables[1].element;
+ expect(element, isNotNull);
+ expect(element.name, 'b');
+ expect(element.nameOffset, newCode.indexOf('b = 2'));
+ }
+ }
+ // verify delta
+ expect(unitDelta.addedDeclarations, unorderedEquals([]));
+ expect(unitDelta.removedDeclarations, unorderedEquals([]));
+ }
+
test_unitMembers_topLevelVariable_add() {
_buildOldUnit(r'''
int a, b;
@@ -585,47 +633,25 @@ int c, d;
]));
}
- test_unitMembers_topLevelVariableDeclaration() {
+ test_unitMembers_topLevelVariable_final() {
_buildOldUnit(r'''
-bool a = 1, b = 2;
-int c = 3;
+final int a = 1;
''');
List<CompilationUnitMember> oldNodes = oldUnit.declarations.toList();
_buildNewUnit(r'''
-int c = 3;
-
-bool a =1, b = 2;
+final int a = 1;
''');
List<CompilationUnitMember> newNodes = newUnit.declarations;
{
TopLevelVariableDeclaration newNode = newNodes[0];
- expect(newNode, same(oldNodes[1]));
- expect(getNodeText(newNode), 'int c = 3;');
- {
- TopLevelVariableElement element =
- newNode.variables.variables[0].element;
- expect(element, isNotNull);
- expect(element.name, 'c');
- expect(element.nameOffset, newCode.indexOf('c = 3'));
- }
- }
- {
- TopLevelVariableDeclaration newNode = newNodes[1];
expect(newNode, same(oldNodes[0]));
- expect(getNodeText(newNode), 'bool a =1, b = 2;');
+ expect(getNodeText(newNode), 'final int a = 1;');
{
TopLevelVariableElement element =
newNode.variables.variables[0].element;
expect(element, isNotNull);
expect(element.name, 'a');
- expect(element.nameOffset, newCode.indexOf('a =1'));
- }
- {
- TopLevelVariableElement element =
- newNode.variables.variables[1].element;
- expect(element, isNotNull);
- expect(element.name, 'b');
- expect(element.nameOffset, newCode.indexOf('b = 2'));
+ expect(element.nameOffset, newCode.indexOf('a = 1'));
}
}
// verify delta
« no previous file with comments | « pkg/analyzer/lib/src/task/incremental_element_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698