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 'package:analysis_testing/mock_sdk.dart'; |
| 6 import 'package:analyzer/src/generated/ast.dart'; |
5 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
| 8 import 'package:analyzer/src/generated/sdk.dart'; |
6 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
7 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
8 import 'package:analyzer/src/generated/ast.dart'; | |
9 | 11 |
10 import '../lib/src/closed_world.dart'; | 12 import '../lib/src/closed_world.dart'; |
11 import '../lib/src/driver.dart'; | 13 import '../lib/src/driver.dart'; |
12 | 14 |
13 main() { | 15 main() { |
| 16 Driver driver; |
| 17 setUp(() { |
| 18 DartSdk sdk = new MockSdk(); |
| 19 driver = new Driver(sdk); |
| 20 }); |
| 21 |
14 test('setFakeRoot', () { | 22 test('setFakeRoot', () { |
15 Driver driver = new Driver(); | |
16 var contents = 'main() {}'; | 23 var contents = 'main() {}'; |
17 Source source = driver.setFakeRoot(contents); | 24 Source source = driver.setFakeRoot(contents); |
18 expect(driver.context.getContents(source).data, equals(contents)); | 25 expect(driver.context.getContents(source).data, equals(contents)); |
19 }); | 26 }); |
20 | 27 |
21 test('resolveEntryPoint', () { | 28 test('resolveEntryPoint', () { |
22 Driver driver = new Driver(); | |
23 String contents = 'main() {}'; | 29 String contents = 'main() {}'; |
24 FunctionElement element = | 30 FunctionElement element = |
25 driver.resolveEntryPoint(driver.setFakeRoot(contents)); | 31 driver.resolveEntryPoint(driver.setFakeRoot(contents)); |
26 expect(element.name, equals('main')); | 32 expect(element.name, equals('main')); |
27 }); | 33 }); |
28 | 34 |
29 test('computeWorld', () { | 35 test('computeWorld', () { |
30 Driver driver = new Driver(); | |
31 String contents = ''' | 36 String contents = ''' |
32 main() { | 37 main() { |
33 foo(); | 38 foo(); |
34 } | 39 } |
35 | 40 |
36 foo() { | 41 foo() { |
37 } | 42 } |
38 | 43 |
39 bar() { | 44 bar() { |
40 } | 45 } |
(...skipping 15 matching lines...) Expand all Loading... |
56 FunctionElement fooElement = functions['foo']; | 61 FunctionElement fooElement = functions['foo']; |
57 expect(world.executableElements.keys, contains(fooElement)); | 62 expect(world.executableElements.keys, contains(fooElement)); |
58 FunctionDeclaration fooAst = world.executableElements[fooElement]; | 63 FunctionDeclaration fooAst = world.executableElements[fooElement]; |
59 expect(fooAst.element, equals(fooElement)); | 64 expect(fooAst.element, equals(fooElement)); |
60 FunctionElement barElement = functions['bar']; | 65 FunctionElement barElement = functions['bar']; |
61 expect( | 66 expect( |
62 world.executableElements.keys, | 67 world.executableElements.keys, |
63 isNot(contains(functions[barElement]))); | 68 isNot(contains(functions[barElement]))); |
64 }); | 69 }); |
65 } | 70 } |
OLD | NEW |