| 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 import 'mock_sdk.dart'; | 5 import 'mock_sdk.dart'; |
| 6 import 'package:analyzer/file_system/memory_file_system.dart'; | 6 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/sdk.dart'; | 9 import 'package:analyzer/src/generated/sdk.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| 11 import 'package:compiler/implementation/dart2jslib.dart' show NullSink; |
| 11 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
| 12 | 13 |
| 13 import '../lib/src/closed_world.dart'; | 14 import '../lib/src/closed_world.dart'; |
| 14 import '../lib/src/driver.dart'; | 15 import '../lib/src/driver.dart'; |
| 15 | 16 |
| 16 main() { | 17 main() { |
| 17 test('Toplevel function', () { | 18 test('Toplevel function', () { |
| 18 var helper = new TreeShakerTestHelper(''' | 19 var helper = new TreeShakerTestHelper(''' |
| 19 main() { | 20 main() { |
| 20 foo(); | 21 foo(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 */ | 170 */ |
| 170 Map<String, ClassDeclaration> instantiatedClasses = <String, | 171 Map<String, ClassDeclaration> instantiatedClasses = <String, |
| 171 ClassDeclaration>{}; | 172 ClassDeclaration>{}; |
| 172 | 173 |
| 173 /** | 174 /** |
| 174 * Create a TreeShakerTestHelper based on the given file contents. | 175 * Create a TreeShakerTestHelper based on the given file contents. |
| 175 */ | 176 */ |
| 176 TreeShakerTestHelper(String contents) { | 177 TreeShakerTestHelper(String contents) { |
| 177 MemoryResourceProvider provider = new MemoryResourceProvider(); | 178 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 178 DartSdk sdk = new MockSdk(); | 179 DartSdk sdk = new MockSdk(); |
| 179 Driver driver = new Driver(provider, sdk); | 180 Driver driver = new Driver(provider, sdk, NullSink.outputProvider); |
| 180 provider.newFile(rootFile, contents); | 181 provider.newFile(rootFile, contents); |
| 181 Source rootSource = driver.setRoot(rootFile); | 182 Source rootSource = driver.setRoot(rootFile); |
| 182 FunctionElement entryPoint = driver.resolveEntryPoint(rootSource); | 183 FunctionElement entryPoint = driver.resolveEntryPoint(rootSource); |
| 183 world = driver.computeWorld(entryPoint); | 184 world = driver.computeWorld(entryPoint); |
| 184 world.executableElements.forEach( | 185 world.executableElements.forEach( |
| 185 (ExecutableElement element, Declaration node) { | 186 (ExecutableElement element, Declaration node) { |
| 186 if (element is FunctionElement) { | 187 if (element is FunctionElement) { |
| 187 FunctionDeclaration declaration = node as FunctionDeclaration; | 188 FunctionDeclaration declaration = node as FunctionDeclaration; |
| 188 expect(declaration, isNotNull); | 189 expect(declaration, isNotNull); |
| 189 expect(declaration.element, equals(element)); | 190 expect(declaration.element, equals(element)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 /** | 293 /** |
| 293 * Asserts that [world] doesn't contain a method with the given qualified | 294 * Asserts that [world] doesn't contain a method with the given qualified |
| 294 * name. | 295 * name. |
| 295 * | 296 * |
| 296 * [qualifiedName] - the qualified name in form 'className.methodName'. | 297 * [qualifiedName] - the qualified name in form 'className.methodName'. |
| 297 */ | 298 */ |
| 298 void assertNoMethod(String qualifiedName) { | 299 void assertNoMethod(String qualifiedName) { |
| 299 expect(methods, isNot(contains(qualifiedName))); | 300 expect(methods, isNot(contains(qualifiedName))); |
| 300 } | 301 } |
| 301 } | 302 } |
| OLD | NEW |