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

Side by Side Diff: tests/compiler/dart2js/constant_expression_evaluate_test.dart

Issue 2118763002: Revert "Handle fields with initializers in constant constructors." (Closed) Base URL: https://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 unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.constants.expressions.evaluate_test; 5 library dart2js.constants.expressions.evaluate_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/constants/evaluation.dart'; 10 import 'package:compiler/src/constants/evaluation.dart';
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 class B { 102 class B {
103 final field1; 103 final field1;
104 const B(this.field1); 104 const B(this.field1);
105 } 105 }
106 class C extends B { 106 class C extends B {
107 final field2; 107 final field2;
108 const C({field1: 42, this.field2: false}) : super(field1); 108 const C({field1: 42, this.field2: false}) : super(field1);
109 const C.named([field = false]) : this(field1: field, field2: field); 109 const C.named([field = false]) : this(field1: field, field2: field);
110 } 110 }
111 class D extends C {
112 final field3 = 99;
113 const D(a, b) : super(field2: a, field1: b);
114 }
115 ''', const [ 111 ''', const [
116 const ConstantData('const Object()', 112 const ConstantData('const Object()',
117 const { const {} : 'ConstructedConstant(Object())' }), 113 const { const {} : 'ConstructedConstant(Object())' }),
118 const ConstantData('const A()', 114 const ConstantData('const A()',
119 const { const {} : 'ConstructedConstant(A())' }), 115 const { const {} : 'ConstructedConstant(A())' }),
120 const ConstantData('const B(0)', 116 const ConstantData('const B(0)',
121 const { const {} : 'ConstructedConstant(B(field1=IntConstant(0)))' }), 117 const { const {} : 'ConstructedConstant(B(field1=IntConstant(0)))' }),
122 const ConstantData('const B(const A())', 118 const ConstantData('const B(const A())',
123 const { const {} : 119 const { const {} :
124 'ConstructedConstant(B(field1=ConstructedConstant(A())))' }), 120 'ConstructedConstant(B(field1=ConstructedConstant(A())))' }),
(...skipping 12 matching lines...) Expand all
137 const ConstantData('const C.named(87)', const { const {} : 133 const ConstantData('const C.named(87)', const { const {} :
138 'ConstructedConstant(C(field1=IntConstant(87),' 134 'ConstructedConstant(C(field1=IntConstant(87),'
139 'field2=IntConstant(87)))' }), 135 'field2=IntConstant(87)))' }),
140 const ConstantData('const C(field1: a, field2: b)', const { 136 const ConstantData('const C(field1: a, field2: b)', const {
141 const {} : 137 const {} :
142 'ConstructedConstant(C(field1=BoolConstant(true),' 138 'ConstructedConstant(C(field1=BoolConstant(true),'
143 'field2=IntConstant(42)))', 139 'field2=IntConstant(42)))',
144 const {'foo': 'false', 'bar': '87'} : 140 const {'foo': 'false', 'bar': '87'} :
145 'ConstructedConstant(C(field1=BoolConstant(false),' 141 'ConstructedConstant(C(field1=BoolConstant(false),'
146 'field2=IntConstant(87)))', }), 142 'field2=IntConstant(87)))', }),
147 const ConstantData('const D(42, 87)', const { const {} :
148 'ConstructedConstant(D(field1=IntConstant(87),'
149 'field2=IntConstant(42),'
150 'field3=IntConstant(99)))' }),
151 ]), 143 ]),
152 const TestData(''' 144 const TestData('''
153 class A<T> implements B { 145 class A<T> implements B {
154 final field1; 146 final field1;
155 const A({this.field1:42}); 147 const A({this.field1:42});
156 } 148 }
157 class B<S> implements C { 149 class B<S> implements C {
158 const factory B({field1}) = A<B<S>>; 150 const factory B({field1}) = A<B<S>>;
159 const factory B.named() = A<S>; 151 const factory B.named() = A<S>;
160 } 152 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Environment environment = new MemoryEnvironment(compiler, env); 229 Environment environment = new MemoryEnvironment(compiler, env);
238 ConstantValue value = 230 ConstantValue value =
239 constant.evaluate(environment, DART_CONSTANT_SYSTEM); 231 constant.evaluate(environment, DART_CONSTANT_SYSTEM);
240 String valueText = value.toStructuredText(); 232 String valueText = value.toStructuredText();
241 Expect.equals(expectedText, valueText, 233 Expect.equals(expectedText, valueText,
242 "Unexpected value '${valueText}' for contant " 234 "Unexpected value '${valueText}' for contant "
243 "`${constant.toDartText()}`, expected '${expectedText}'."); 235 "`${constant.toDartText()}`, expected '${expectedText}'.");
244 }); 236 });
245 }); 237 });
246 } 238 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698