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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1864753002: Use isValidConst flag to distinguish between const / final expressions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge and tweaks. Created 4 years, 8 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/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index dab2b108f9c8b7cceb08cd8324b197df2e0513ee..aa938d7571f3ecbd6cabade9e5b2fe0bc633f8d3 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -147,6 +147,7 @@ class ResynthesizeElementTest extends ResynthesizeTest {
@reflectiveTest
abstract class ResynthesizeTest extends AbstractSingleUnitTest {
Set<Source> otherLibrarySources = new Set<Source>();
+ bool constantInitializersAreInvalid = false;
bool get checkPropagatedTypes => true;
@@ -430,7 +431,11 @@ abstract class ResynthesizeTest extends AbstractSingleUnitTest {
} else if (oItem is ConstructorFieldInitializer &&
rItem is ConstructorFieldInitializer) {
compareConstAsts(rItem.fieldName, oItem.fieldName, desc);
- compareConstAsts(rItem.expression, oItem.expression, desc);
+ if (constantInitializersAreInvalid) {
+ _assertUnresolvedIdentifier(rItem.expression, desc);
+ } else {
+ compareConstAsts(rItem.expression, oItem.expression, desc);
+ }
} else if (oItem is SuperConstructorInvocation &&
rItem is SuperConstructorInvocation) {
compareElements(rItem.staticElement, oItem.staticElement, desc);
@@ -1163,8 +1168,12 @@ abstract class ResynthesizeTest extends AbstractSingleUnitTest {
resynthesized.constantValue, original.constantValue, desc);
} else {
Expression initializer = resynthesizedActual.constantInitializer;
- compareConstAsts(initializer, originalActual.constantInitializer,
- '$desc initializer');
+ if (constantInitializersAreInvalid) {
+ _assertUnresolvedIdentifier(initializer, desc);
+ } else {
+ compareConstAsts(initializer, originalActual.constantInitializer,
+ '$desc initializer');
+ }
}
}
checkPossibleMember(resynthesized, original, desc);
@@ -1291,17 +1300,6 @@ abstract class ResynthesizeTest extends AbstractSingleUnitTest {
prepareAnalysisContext(createOptions());
}
- test_const_invalid_field_const() {
- checkLibrary(
- r'''
-class C {
- static const f = 1 + foo();
-}
-int foo() => 42;
-''',
- allowErrors: true);
- }
-
test_class_abstract() {
checkLibrary('abstract class C {}');
}
@@ -1639,7 +1637,20 @@ f() {
''');
}
+ test_const_invalid_field_const() {
+ constantInitializersAreInvalid = true;
+ checkLibrary(
+ r'''
+class C {
+ static const f = 1 + foo();
+}
+int foo() => 42;
+''',
+ allowErrors: true);
+ }
+
test_const_invalid_field_final() {
+ constantInitializersAreInvalid = true;
checkLibrary(
r'''
class C {
@@ -1651,6 +1662,7 @@ int foo() => 42;
}
test_const_invalid_topLevel() {
+ constantInitializersAreInvalid = true;
checkLibrary(
r'''
const v = 1 + foo();
@@ -2393,6 +2405,7 @@ class C {
}
test_constructor_initializers_field_notConst() {
+ constantInitializersAreInvalid = true;
checkLibrary(
'''
class C {
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_const_expr.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698