Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: pkg/analyzer2dart/test/tree_shaker_test.dart

Issue 548253003: First end-to-end capability in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/test/end2end_test.dart ('k') | sdk/lib/_internal/compiler/implementation/dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698