| OLD | NEW |
| 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 // Test that elements are not needlessly required by dart2js. | 5 // Test that elements are not needlessly required by dart2js. |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
| 9 import 'package:compiler/src/elements/elements.dart'; | 9 import 'package:compiler/src/elements/elements.dart'; |
| 10 import 'package:compiler/src/enqueue.dart'; | 10 import 'package:compiler/src/enqueue.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 {bool proxyConstantComputed: false, bool deprecatedClass: false}) async { | 37 {bool proxyConstantComputed: false, bool deprecatedClass: false}) async { |
| 38 CompilationResult result = await runCompiler( | 38 CompilationResult result = await runCompiler( |
| 39 memorySourceFiles: {'main.dart': code}, options: ['--analyze-only']); | 39 memorySourceFiles: {'main.dart': code}, options: ['--analyze-only']); |
| 40 Expect.isTrue(result.isSuccess); | 40 Expect.isTrue(result.isSuccess); |
| 41 Compiler compiler = result.compiler; | 41 Compiler compiler = result.compiler; |
| 42 Expect.equals( | 42 Expect.equals( |
| 43 proxyConstantComputed, | 43 proxyConstantComputed, |
| 44 compiler.resolution.wasProxyConstantComputedTestingOnly, | 44 compiler.resolution.wasProxyConstantComputedTestingOnly, |
| 45 "Unexpected computation of proxy constant."); | 45 "Unexpected computation of proxy constant."); |
| 46 | 46 |
| 47 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; |
| 47 checkInstantiated( | 48 checkInstantiated( |
| 48 compiler, | 49 compiler, coreLibrary.find('_Proxy'), proxyConstantComputed); |
| 49 compiler.commonElements.coreLibrary.find('_Proxy'), | 50 checkInstantiated(compiler, coreLibrary.find('Deprecated'), deprecatedClass); |
| 50 proxyConstantComputed); | |
| 51 checkInstantiated(compiler, | |
| 52 compiler.commonElements.coreLibrary.find('Deprecated'), deprecatedClass); | |
| 53 | 51 |
| 54 LibraryElement jsHelperLibrary = | 52 LibraryElement jsHelperLibrary = |
| 55 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER); | 53 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER); |
| 56 jsHelperLibrary.forEachLocalMember((Element element) { | 54 jsHelperLibrary.forEachLocalMember((Element element) { |
| 57 Uri uri = element.compilationUnit.script.resourceUri; | 55 Uri uri = element.compilationUnit.script.resourceUri; |
| 58 if (element.isClass && uri.path.endsWith('annotations.dart')) { | 56 if (element.isClass && uri.path.endsWith('annotations.dart')) { |
| 59 checkInstantiated(compiler, element, false); | 57 checkInstantiated(compiler, element, false); |
| 60 } | 58 } |
| 61 }); | 59 }); |
| 62 } | 60 } |
| OLD | NEW |