| 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 21 matching lines...) Expand all Loading... |
| 32 Expect.equals( | 32 Expect.equals( |
| 33 expected, isProcessed, 'Unexpected processing state of class $cls.'); | 33 expected, isProcessed, 'Unexpected processing state of class $cls.'); |
| 34 } | 34 } |
| 35 | 35 |
| 36 analyze(String code, | 36 analyze(String code, |
| 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(proxyConstantComputed, | 42 Expect.equals( |
| 43 proxyConstantComputed, |
| 43 compiler.resolution.wasProxyConstantComputedTestingOnly, | 44 compiler.resolution.wasProxyConstantComputedTestingOnly, |
| 44 "Unexpected computation of proxy constant."); | 45 "Unexpected computation of proxy constant."); |
| 45 | 46 |
| 46 checkInstantiated( | 47 checkInstantiated( |
| 47 compiler, compiler.commonElements.coreLibrary.find('_Proxy'), | 48 compiler, |
| 49 compiler.commonElements.coreLibrary.find('_Proxy'), |
| 48 proxyConstantComputed); | 50 proxyConstantComputed); |
| 49 checkInstantiated( | 51 checkInstantiated(compiler, |
| 50 compiler, compiler.commonElements.coreLibrary.find('Deprecated'), | 52 compiler.commonElements.coreLibrary.find('Deprecated'), deprecatedClass); |
| 51 deprecatedClass); | |
| 52 | 53 |
| 53 LibraryElement jsHelperLibrary = | 54 LibraryElement jsHelperLibrary = |
| 54 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER); | 55 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER); |
| 55 jsHelperLibrary.forEachLocalMember((Element element) { | 56 jsHelperLibrary.forEachLocalMember((Element element) { |
| 56 Uri uri = element.compilationUnit.script.resourceUri; | 57 Uri uri = element.compilationUnit.script.resourceUri; |
| 57 if (element.isClass && uri.path.endsWith('annotations.dart')) { | 58 if (element.isClass && uri.path.endsWith('annotations.dart')) { |
| 58 checkInstantiated(compiler, element, false); | 59 checkInstantiated(compiler, element, false); |
| 59 } | 60 } |
| 60 }); | 61 }); |
| 61 } | 62 } |
| OLD | NEW |