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

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

Issue 1696193003: Fix cache corruption in incremental resolver (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
Index: pkg/analyzer/test/generated/incremental_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/incremental_resolver_test.dart b/pkg/analyzer/test/generated/incremental_resolver_test.dart
index 5c52f176d18ffb7bf8479351fc83de08194bc62a..9ee7ea183e1d5f3e57322c7b85c419529ebfb01c 100644
--- a/pkg/analyzer/test/generated/incremental_resolver_test.dart
+++ b/pkg/analyzer/test/generated/incremental_resolver_test.dart
@@ -3501,11 +3501,7 @@ class B {
}
_checkCacheEntries(cache);
- try {
- assertSameResolution(unit, fullNewUnit);
- } on IncrementalResolutionMismatch catch (mismatch) {
- fail(mismatch.message);
- }
+ assertSameResolution(unit, fullNewUnit);
// errors
List<AnalysisError> newFullErrors =
analysisContext.getErrors(source).errors;
@@ -4849,11 +4845,44 @@ class B extends A {}
}
}
- void _assertCacheResults({bool expectCachePostConstantsValid: true}) {
+ void test_updateFunctionToForLoop() {
+ _resolveUnit(r'''
+class PlayDrag {
+ final List<num> times = new List<num>();
+
+ PlayDrag.start() {}
+
+ void update(num pos) {
+ fo (int i = times.length - 2; i >= 0; i--) {}
+ }
+}
+''');
+
+ _updateAndValidate(
+ r'''
+class PlayDrag {
+ final List<num> times = new List<num>();
+
+ PlayDrag.start() {}
+
+ void update(num pos) {
+ for (int i = times.length - 2; i >= 0; i--) {}
+ }
+}
+''',
+ expectLibraryUnchanged: false);
+ }
+
+ void _assertCacheResults(
+ {bool expectLibraryUnchanged: true,
+ bool expectCachePostConstantsValid: true}) {
_assertCacheSourceResult(TOKEN_STREAM);
_assertCacheSourceResult(SCAN_ERRORS);
_assertCacheSourceResult(PARSED_UNIT);
_assertCacheSourceResult(PARSE_ERRORS);
+ if (!expectLibraryUnchanged) {
+ return;
+ }
_assertCacheSourceResult(LIBRARY_ELEMENT1);
_assertCacheSourceResult(LIBRARY_ELEMENT2);
_assertCacheSourceResult(LIBRARY_ELEMENT3);
@@ -4943,6 +4972,7 @@ class B extends A {}
void _updateAndValidate(String newCode,
{bool expectedSuccess: true,
+ bool expectLibraryUnchanged: true,
bool expectCachePostConstantsValid: true,
bool compareWithFull: true,
bool runTasksBeforeIncremental: true}) {
@@ -4955,7 +4985,9 @@ class B extends A {}
_resetWithIncremental(true);
analysisContext2.setContents(source, newCode);
CompilationUnit newUnit = resolveCompilationUnit(source, oldLibrary);
- expect(logger.hasError, isFalse);
+ if (logger.hasError) {
+ fail("logged an error: ${logger.lastError}");
+ }
List<AnalysisError> newErrors = analysisContext.computeErrors(source);
LineInfo newLineInfo = analysisContext.getLineInfo(source);
// check for expected failure
@@ -4966,6 +4998,7 @@ class B extends A {}
// The cache must still have enough results to make the incremental
// resolution useful.
_assertCacheResults(
+ expectLibraryUnchanged: expectLibraryUnchanged,
expectCachePostConstantsValid: expectCachePostConstantsValid);
// The existing CompilationUnit[Element] should be updated.
expect(newUnit, same(oldUnit));
@@ -5255,7 +5288,9 @@ class _Edit {
}
class _TestLogger implements logging.Logger {
- bool hasError = false;
+ Object lastError;
+
+ bool get hasError => lastError != null;
@override
void enter(String name) {}
@@ -5268,7 +5303,7 @@ class _TestLogger implements logging.Logger {
@override
void logException(Object exception, [Object stackTrace]) {
- hasError = true;
+ lastError = exception;
Brian Wilkerson 2016/02/16 15:10:48 Seems like it would be useful to also capture the
skybrian 2016/02/17 01:23:41 Done.
}
@override

Powered by Google App Engine
This is Rietveld 408576698