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

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

Issue 1916053003: Add toStructuredText to ConstantExpression and align method names with ConstantValue (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt 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 unified diff | Download patch
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 constant_expression_test; 5 library constant_expression_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/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 CompilationResult result = await runCompiler( 211 CompilationResult result = await runCompiler(
212 memorySourceFiles: {'main.dart': source}, 212 memorySourceFiles: {'main.dart': source},
213 options: ['--analyze-all']); 213 options: ['--analyze-all']);
214 Compiler compiler = result.compiler; 214 Compiler compiler = result.compiler;
215 var library = compiler.mainApp; 215 var library = compiler.mainApp;
216 constants.forEach((String name, ConstantData data) { 216 constants.forEach((String name, ConstantData data) {
217 FieldElement field = library.localLookup(name); 217 FieldElement field = library.localLookup(name);
218 var constant = field.constant; 218 var constant = field.constant;
219 Expect.equals(data.kind, constant.kind, 219 Expect.equals(data.kind, constant.kind,
220 "Unexpected kind '${constant.kind}' for contant " 220 "Unexpected kind '${constant.kind}' for contant "
221 "`${constant.getText()}`, expected '${data.kind}'."); 221 "`${constant.toDartText()}`, expected '${data.kind}'.");
222 Expect.equals(data.text, constant.getText(), 222 Expect.equals(data.text, constant.toDartText(),
223 "Unexpected text '${constant.getText()}' for contant, " 223 "Unexpected text '${constant.toDartText()}' for contant, "
224 "expected '${data.text}'."); 224 "expected '${data.text}'.");
225 if (data.type != null) { 225 if (data.type != null) {
226 String instanceType = constant.computeInstanceType().toString(); 226 String instanceType = constant.computeInstanceType().toString();
227 Expect.equals(data.type, instanceType, 227 Expect.equals(data.type, instanceType,
228 "Unexpected type '$instanceType' for contant " 228 "Unexpected type '$instanceType' for contant "
229 "`${constant.getText()}`, expected '${data.type}'."); 229 "`${constant.toDartText()}`, expected '${data.type}'.");
230 } 230 }
231 if (data.fields != null) { 231 if (data.fields != null) {
232 Map instanceFields = constant.computeInstanceFields(); 232 Map instanceFields = constant.computeInstanceFields();
233 Expect.equals(data.fields.length, instanceFields.length, 233 Expect.equals(data.fields.length, instanceFields.length,
234 "Unexpected field count ${instanceFields.length} for contant " 234 "Unexpected field count ${instanceFields.length} for contant "
235 "`${constant.getText()}`, expected '${data.fields.length}'."); 235 "`${constant.toDartText()}`, expected '${data.fields.length}'.");
236 instanceFields.forEach((field, expression) { 236 instanceFields.forEach((field, expression) {
237 String name = '$field'; 237 String name = '$field';
238 String expression = instanceFields[field].getText(); 238 String expression = instanceFields[field].toDartText();
239 String expected = data.fields[name]; 239 String expected = data.fields[name];
240 Expect.equals(expected, expression, 240 Expect.equals(expected, expression,
241 "Unexpected field expression ${expression} for field '$name' in " 241 "Unexpected field expression ${expression} for field '$name' in "
242 "contant `${constant.getText()}`, expected '${expected}'."); 242 "contant `${constant.toDartText()}`, expected '${expected}'.");
243 }); 243 });
244 } 244 }
245 }); 245 });
246 } 246 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/constant_expression_evaluate_test.dart ('k') | tests/compiler/dart2js/mirrors_used_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698