| OLD | NEW |
| 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 '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:compiler/implementation/constants/values.dart'; | 9 import 'package:compiler/implementation/constants/values.dart'; |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 packageRoot, | 32 packageRoot, |
| 33 [], | 33 [], |
| 34 {}); | 34 {}); |
| 35 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 35 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 36 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 36 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 37 var outputUnitForConstant = compiler.deferredLoadTask.outputUnitForConstant; | 37 var outputUnitForConstant = compiler.deferredLoadTask.outputUnitForConstant; |
| 38 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 38 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 39 var lib = | 39 var lib = |
| 40 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); | 40 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); |
| 41 var backend = compiler.backend; | 41 var backend = compiler.backend; |
| 42 List<Constant> allConstants = []; | 42 List<ConstantValue> allConstants = []; |
| 43 | 43 |
| 44 addConstantWithDependendencies(Constant c) { | 44 addConstantWithDependendencies(ConstantValue c) { |
| 45 allConstants.add(c); | 45 allConstants.add(c); |
| 46 c.getDependencies().forEach(addConstantWithDependendencies); | 46 c.getDependencies().forEach(addConstantWithDependendencies); |
| 47 } | 47 } |
| 48 | 48 |
| 49 backend.constants.compiledConstants.forEach(addConstantWithDependendencies); | 49 backend.constants.compiledConstants.forEach(addConstantWithDependendencies); |
| 50 for (String stringValue in ["cA", "cB", "cC"]) { | 50 for (String stringValue in ["cA", "cB", "cC"]) { |
| 51 Constant constant = allConstants.firstWhere((constant) { | 51 ConstantValue constant = allConstants.firstWhere((constant) { |
| 52 return constant is StringConstant | 52 return constant.isString |
| 53 && constant.value.slowToString() == stringValue; | 53 && constant.primitiveValue.slowToString() == stringValue; |
| 54 }); | 54 }); |
| 55 Expect.notEquals(null, outputUnitForConstant(constant)); | 55 Expect.notEquals(null, outputUnitForConstant(constant)); |
| 56 Expect.notEquals(mainOutputUnit, outputUnitForConstant(constant)); | 56 Expect.notEquals(mainOutputUnit, outputUnitForConstant(constant)); |
| 57 } | 57 } |
| 58 })); | 58 })); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and | 61 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and |
| 62 // lib2.foo2. This should trigger seperate outputunits for main, lib1 and lib2. | 62 // lib2.foo2. This should trigger seperate outputunits for main, lib1 and lib2. |
| 63 // | 63 // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 print(lib.L); | 75 print(lib.L); |
| 76 } | 76 } |
| 77 """, "lib.dart": """ | 77 """, "lib.dart": """ |
| 78 class C { | 78 class C { |
| 79 final a; | 79 final a; |
| 80 const C(this.a); | 80 const C(this.a); |
| 81 } | 81 } |
| 82 | 82 |
| 83 const L = const {"cA": const C(const {"cB": "cC"})}; | 83 const L = const {"cA": const C(const {"cB": "cC"})}; |
| 84 """,}; | 84 """,}; |
| OLD | NEW |