| 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/common/names.dart'; |
| 8 import 'package:compiler/src/compiler.dart'; | 9 import 'package:compiler/src/compiler.dart'; |
| 9 import 'package:compiler/src/elements/elements.dart'; | 10 import 'package:compiler/src/elements/elements.dart'; |
| 10 import 'package:compiler/src/enqueue.dart'; | 11 import 'package:compiler/src/enqueue.dart'; |
| 11 import 'package:compiler/src/js_backend/backend_helpers.dart'; | 12 import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend; |
| 12 import 'package:expect/expect.dart'; | 13 import 'package:expect/expect.dart'; |
| 13 import 'memory_compiler.dart'; | 14 import 'memory_compiler.dart'; |
| 14 | 15 |
| 15 main() { | 16 main() { |
| 16 asyncTest(() async { | 17 asyncTest(() async { |
| 17 await analyze('main() {}'); | 18 await analyze('main() {}'); |
| 18 await analyze('main() => proxy;', proxyConstantComputed: true); | 19 await analyze('main() => proxy;', proxyConstantComputed: true); |
| 19 await analyze('@deprecated main() {}'); | 20 await analyze('@deprecated main() {}'); |
| 20 await analyze('@deprecated main() => deprecated;', deprecatedClass: true); | 21 await analyze('@deprecated main() => deprecated;', deprecatedClass: true); |
| 21 await analyze('main() => deprecated;', deprecatedClass: true); | 22 await analyze('main() => deprecated;', deprecatedClass: true); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 proxyConstantComputed, | 44 proxyConstantComputed, |
| 44 compiler.resolution.wasProxyConstantComputedTestingOnly, | 45 compiler.resolution.wasProxyConstantComputedTestingOnly, |
| 45 "Unexpected computation of proxy constant."); | 46 "Unexpected computation of proxy constant."); |
| 46 | 47 |
| 47 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; | 48 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; |
| 48 checkInstantiated( | 49 checkInstantiated( |
| 49 compiler, coreLibrary.find('_Proxy'), proxyConstantComputed); | 50 compiler, coreLibrary.find('_Proxy'), proxyConstantComputed); |
| 50 checkInstantiated(compiler, coreLibrary.find('Deprecated'), deprecatedClass); | 51 checkInstantiated(compiler, coreLibrary.find('Deprecated'), deprecatedClass); |
| 51 | 52 |
| 52 LibraryElement jsHelperLibrary = | 53 LibraryElement jsHelperLibrary = |
| 53 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER); | 54 compiler.libraryLoader.lookupLibrary(Uris.dart__js_helper); |
| 54 jsHelperLibrary.forEachLocalMember((Element element) { | 55 jsHelperLibrary.forEachLocalMember((Element element) { |
| 55 Uri uri = element.compilationUnit.script.resourceUri; | 56 Uri uri = element.compilationUnit.script.resourceUri; |
| 56 if (element.isClass && uri.path.endsWith('annotations.dart')) { | 57 if (element.isClass && uri.path.endsWith('annotations.dart')) { |
| 57 checkInstantiated(compiler, element, false); | 58 checkInstantiated(compiler, element, false); |
| 58 } | 59 } |
| 59 }); | 60 }); |
| 60 } | 61 } |
| OLD | NEW |