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

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

Issue 2037123002: Cleanup: remove package "analyzer2dart". (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « pkg/analyzer2dart/lib/src/util.dart ('k') | pkg/analyzer2dart/test/end2end_data.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'mock_sdk.dart';
6 import 'package:analyzer/file_system/memory_file_system.dart';
7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/sdk.dart';
10 import 'package:analyzer/src/generated/source.dart';
11 import 'package:compiler/src/dart2jslib.dart' show NullSink;
12 import 'package:unittest/unittest.dart';
13
14 import '../lib/src/closed_world.dart';
15 import '../lib/src/driver.dart';
16
17 main() {
18 MemoryResourceProvider provider;
19 Driver driver;
20 setUp(() {
21 provider = new MemoryResourceProvider();
22 DartSdk sdk = new MockSdk();
23 driver = new Driver(provider, sdk, NullSink.outputProvider);
24 });
25
26 Source setFakeRoot(String contents) {
27 String path = '/root.dart';
28 provider.newFile(path, contents);
29 return driver.setRoot(path);
30 }
31
32 test('resolveEntryPoint', () {
33 String contents = 'main() {}';
34 Source source = setFakeRoot(contents);
35 FunctionElement element = driver.resolveEntryPoint(source);
36 expect(element.name, equals('main'));
37 });
38
39 test('computeWorld', () {
40 String contents = '''
41 main() {
42 foo();
43 }
44
45 foo() {
46 }
47
48 bar() {
49 }
50 ''';
51 Source source = setFakeRoot(contents);
52 FunctionElement entryPoint = driver.resolveEntryPoint(source);
53 ClosedWorld world = driver.computeWorld(entryPoint);
54 expect(world.executableElements, hasLength(2));
55 CompilationUnitElement compilationUnit =
56 entryPoint.getAncestor((e) => e is CompilationUnitElement);
57 Map<String, FunctionElement> functions = {};
58 for (FunctionElement functionElement in compilationUnit.functions) {
59 functions[functionElement.name] = functionElement;
60 }
61 FunctionElement mainElement = functions['main'];
62 expect(world.executableElements.keys, contains(mainElement));
63 FunctionDeclaration mainAst = world.executableElements[mainElement];
64 expect(mainAst.element, equals(mainElement));
65 FunctionElement fooElement = functions['foo'];
66 expect(world.executableElements.keys, contains(fooElement));
67 FunctionDeclaration fooAst = world.executableElements[fooElement];
68 expect(fooAst.element, equals(fooElement));
69 FunctionElement barElement = functions['bar'];
70 expect(
71 world.executableElements.keys,
72 isNot(contains(functions[barElement])));
73 });
74 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/lib/src/util.dart ('k') | pkg/analyzer2dart/test/end2end_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698