Index: pkg/analyzer/test/src/context/context_test.dart |
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart |
index faed064af2962282f4ceb1ee6afbdeb97b0447aa..d0ec5b2caf846d1904e2f845397d03d38a043542 100644 |
--- a/pkg/analyzer/test/src/context/context_test.dart |
+++ b/pkg/analyzer/test/src/context/context_test.dart |
@@ -3801,7 +3801,7 @@ f1() { |
_assertInvalid(a, LIBRARY_ERRORS_READY); |
} |
- void test_sequence_unitConstants() { |
+ void test_sequence_unitConstants_addRemove() { |
Source a = addSource( |
'/a.dart', |
r''' |
@@ -3868,6 +3868,40 @@ baz() { |
expect(newV3.evaluationResult.value.toIntValue(), 30); |
} |
+ void test_sequence_unitConstants_local_insertSpace() { |
+ Source a = addSource( |
+ '/a.dart', |
+ r''' |
+main() { |
+ const C = 1; |
+} |
+'''); |
+ _performPendingAnalysisTasks(); |
+ LibrarySpecificUnit unitA = new LibrarySpecificUnit(a, a); |
+ List<ConstantEvaluationTarget> oldConstants = |
+ context.getResult(unitA, COMPILATION_UNIT_CONSTANTS); |
+ expect(oldConstants, hasLength(1)); |
+ ConstVariableElement C = _findConstVariable(oldConstants, 'C'); |
+ expect(context.analysisCache.get(C), isNotNull); |
+ // Insert a space before the name. |
+ context.setContents( |
+ a, |
+ r''' |
+main() { |
+ const C = 1; |
+} |
+'''); |
+ List<ConstantEvaluationTarget> newConstants = |
+ context.getResult(unitA, COMPILATION_UNIT_CONSTANTS); |
+ expect(newConstants, hasLength(1)); |
+ expect(newConstants, contains(same(C))); |
+ // Perform analysis, compute constant values. |
+ _performPendingAnalysisTasks(); |
+ // Validate const variable values. |
+ expect(context.analysisCache.get(C), isNotNull); |
+ expect(C.evaluationResult.value.toIntValue(), 1); |
+ } |
+ |
void test_sequence_useAnyResolvedUnit() { |
Source a = addSource( |
'/a.dart', |