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

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

Issue 2916893002: Handle int constant (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // Test that constants depended on by other constants are correctly deferred. 5 // Test that constants depended on by other constants are correctly deferred.
6 6
7 import 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import 'package:compiler/src/common.dart'; 8 import 'package:compiler/src/common.dart';
9 import 'package:compiler/src/constants/values.dart'; 9 import 'package:compiler/src/constants/values.dart';
10 import 'package:compiler/src/compiler.dart'; 10 import 'package:compiler/src/compiler.dart';
11 import 'package:expect/expect.dart'; 11 import 'package:expect/expect.dart';
12 import 'memory_compiler.dart'; 12 import 'memory_compiler.dart';
13 13
14 void main() { 14 void main() {
15 asyncTest(() async { 15 asyncTest(() async {
16 CompilationResult result = 16 CompilationResult result =
17 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); 17 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES);
18 Compiler compiler = result.compiler; 18 Compiler compiler = result.compiler;
19 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
20 var outputUnitForConstant = compiler.deferredLoadTask.outputUnitForConstant; 19 var outputUnitForConstant = compiler.deferredLoadTask.outputUnitForConstant;
21 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; 20 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
22 var lib =
23 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart"));
24 var backend = compiler.backend;
25 List<ConstantValue> allConstants = []; 21 List<ConstantValue> allConstants = [];
26 22
27 addConstantWithDependendencies(ConstantValue c) { 23 addConstantWithDependendencies(ConstantValue c) {
28 allConstants.add(c); 24 allConstants.add(c);
29 c.getDependencies().forEach(addConstantWithDependendencies); 25 c.getDependencies().forEach(addConstantWithDependendencies);
30 } 26 }
31 27
32 backend.constants.compiledConstants.forEach(addConstantWithDependendencies); 28 var codegenWorldBuilder = compiler.codegenWorldBuilder;
29 codegenWorldBuilder.compiledConstants
30 .forEach(addConstantWithDependendencies);
33 for (String stringValue in ["cA", "cB", "cC"]) { 31 for (String stringValue in ["cA", "cB", "cC"]) {
34 ConstantValue constant = allConstants.firstWhere((constant) { 32 ConstantValue constant = allConstants.firstWhere((constant) {
35 return constant.isString && constant.primitiveValue == stringValue; 33 return constant.isString && constant.primitiveValue == stringValue;
36 }); 34 });
37 Expect.notEquals(null, outputUnitForConstant(constant), 35 Expect.notEquals(null, outputUnitForConstant(constant),
38 "Constant value ${constant.toStructuredText()} has no output unit."); 36 "Constant value ${constant.toStructuredText()} has no output unit.");
39 Expect.notEquals( 37 Expect.notEquals(
40 mainOutputUnit, 38 mainOutputUnit,
41 outputUnitForConstant(constant), 39 outputUnitForConstant(constant),
42 "Constant value ${constant.toStructuredText()} " 40 "Constant value ${constant.toStructuredText()} "
(...skipping 22 matching lines...) Expand all
65 """, 63 """,
66 "lib.dart": """ 64 "lib.dart": """
67 class C { 65 class C {
68 final a; 66 final a;
69 const C(this.a); 67 const C(this.a);
70 } 68 }
71 69
72 const L = const {"cA": const C(const {"cB": "cC"})}; 70 const L = const {"cA": const C(const {"cB": "cC"})};
73 """, 71 """,
74 }; 72 };
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/universe/world_builder.dart ('k') | tests/compiler/dart2js/kernel/compile_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698