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

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

Issue 1671293002: Resynthesize default parameter values. (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
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.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/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 1348b8e70a5a92808139e5e34ec5cbc2606b0a82..ee7aa83269576427ec78289d9c984f4d3a069057 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -670,13 +670,13 @@ class ResynthTest extends ResolverTestCase {
VariableElementImpl original, String desc) {
compareElements(resynthesized, original, desc);
compareTypes(resynthesized.type, original.type, desc);
- // TODO(scheglov) implement and validate other constant variable types
- if (shouldCompareConstValues &&
- original is ConstTopLevelVariableElementImpl) {
- compareConstantExpressions(resynthesized.constantInitializer,
- original.constantInitializer, desc);
+ // TODO(scheglov) enable for any ConstVariableElement
+ if (shouldCompareConstValues) {
+ if (original is ConstVariableElement) {
+ compareConstantExpressions(resynthesized.constantInitializer,
+ original.constantInitializer, desc);
+ }
}
- // TODO(paulberry): test initializer
}
/**
@@ -1333,6 +1333,49 @@ const v = C.length;
''');
}
+ test_const_parameterDefaultValue_initializingFormal_functionTyped() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {
+ final x;
+ const C({this.x: foo});
+}
+int foo() => 42;
+''');
+ }
+
+ test_const_parameterDefaultValue_initializingFormal_named() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {
+ final x;
+ const C({this.x: 1 + 2});
+}
+''');
+ }
+
+ test_const_parameterDefaultValue_initializingFormal_positional() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {
+ final x;
+ const C([this.x = 1 + 2]);
+}
+''');
+ }
+
+ test_const_parameterDefaultValue_normal() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {
+ const C.positional([p = 1 + 2]);
+ const C.named({p: 1 + 2});
+ void methodPositional([p = 1 + 2]) {}
+ void methodNamed({p: 1 + 2}) {}
+}
+''');
+ }
+
test_const_reference_staticField() {
shouldCompareConstValues = true;
checkLibrary(r'''
@@ -1803,7 +1846,7 @@ class C {
}
test_field_propagatedType_final_dep_inLib() {
- addNamedSource('/a.dart', 'final a = 1;');
+ addLibrarySource('/a.dart', 'final a = 1;');
checkLibrary('''
import "a.dart";
class C {
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698