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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2155923002: Update COMPILATION_UNIT_CONSTANTS after incremental elements building. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/dart.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/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 a851f55013cb35dd0e1293a146ce75ee23a92449..50b9f779c6f675db24a951b78148c04250544801 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -16,6 +16,7 @@ import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/cancelable_future.dart';
import 'package:analyzer/src/context/cache.dart';
import 'package:analyzer/src/context/context.dart';
+import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/scanner/scanner.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error.dart';
@@ -3390,6 +3391,47 @@ class B {
expect(context.getErrors(b).errors, hasLength(0));
}
+ void test_sequence_unitConstants() {
+ Source a = addSource(
+ '/a.dart',
+ r'''
+const A = 1;
+const B = 2;
+const C = 3;
+''');
+ _performPendingAnalysisTasks();
+ LibrarySpecificUnit unitA = new LibrarySpecificUnit(a, a);
+ expect(context.getResult(unitA, COMPILATION_UNIT_CONSTANTS), hasLength(3));
+ // Update and
+ context.setContents(
+ a,
+ r'''
+const A = 1;
+const B = 2;
+const D = 4;
+main() {
+ const V = 42;
+}
+''');
+ List<ConstantEvaluationTarget> constants =
+ context.getResult(unitA, COMPILATION_UNIT_CONSTANTS);
+ expect(constants, hasLength(4));
+ // Perform analysis, compute constant values.
+ _performPendingAnalysisTasks();
+ // Validate const variable values.
+ Map<String, ConstVariableElement> constVariables =
+ <String, ConstVariableElement>{};
+ constants.forEach((c) {
+ if (c is ConstVariableElement) {
+ constVariables[c.name] = c;
+ }
+ });
+ expect(constVariables['A'].evaluationResult.value.toIntValue(), 1);
+ expect(constVariables['B'].evaluationResult.value.toIntValue(), 2);
+ expect(constVariables['D'].evaluationResult.value.toIntValue(), 4);
+ expect(constVariables['V'].evaluationResult.value.toIntValue(), 42);
+ }
+
void test_sequence_useAnyResolvedUnit() {
Source a = addSource(
'/a.dart',
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698