OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
8 import 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
9 import 'package:compiler/src/diagnostics/messages.dart' show MessageKind; | 9 import 'package:compiler/src/diagnostics/messages.dart' show MessageKind; |
10 import 'package:compiler/src/elements/elements.dart'; | 10 import 'package:compiler/src/elements/elements.dart'; |
11 import 'package:compiler/src/elements/modelx.dart'; | 11 import 'package:compiler/src/elements/modelx.dart'; |
12 import 'package:compiler/src/tree/tree.dart'; | 12 import 'package:compiler/src/tree/tree.dart'; |
13 import 'package:compiler/src/types/types.dart'; | 13 import 'package:compiler/src/types/types.dart'; |
14 import 'package:compiler/src/universe/call_structure.dart' show CallStructure; | 14 import 'package:compiler/src/universe/call_structure.dart' show CallStructure; |
15 import 'package:compiler/src/universe/selector.dart' show Selector; | 15 import 'package:compiler/src/universe/selector.dart' show Selector; |
16 import 'package:compiler/src/world.dart'; | 16 import 'package:compiler/src/world.dart'; |
17 | 17 |
18 import 'mock_compiler.dart'; | 18 import 'mock_compiler.dart'; |
19 import 'mock_libraries.dart'; | 19 import 'mock_libraries.dart'; |
20 | 20 |
21 Future<Compiler> applyPatch(String script, String patch, | 21 Future<Compiler> applyPatch(String script, String patch, |
22 {bool analyzeAll: false, | 22 {bool analyzeAll: false, |
23 bool analyzeOnly: false, | 23 bool analyzeOnly: false, |
24 bool runCompiler: false, | 24 bool runCompiler: false, |
25 String main: "", | 25 String main: "", |
26 String patchVersion}) { | 26 String patchVersion}) async { |
27 Map<String, String> core = <String, String>{'script': script}; | 27 Map<String, String> core = <String, String>{'script': script}; |
28 MockCompiler compiler = new MockCompiler.internal( | 28 MockCompiler compiler = new MockCompiler.internal( |
29 coreSource: core, | 29 coreSource: core, |
30 analyzeAll: analyzeAll, | 30 analyzeAll: analyzeAll, |
31 analyzeOnly: analyzeOnly, | 31 analyzeOnly: analyzeOnly, |
32 patchVersion: patchVersion); | 32 patchVersion: patchVersion); |
33 compiler.diagnosticHandler = createHandler(compiler, ''); | 33 compiler.diagnosticHandler = createHandler(compiler, ''); |
34 var uri = Uri.parse("patch:core"); | 34 var uri = Uri.parse("patch:core"); |
35 compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch"); | 35 compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch"); |
36 var future; | |
37 if (runCompiler) { | 36 if (runCompiler) { |
38 future = compiler.run(null, main); | 37 await compiler.run(null, main); |
39 } else { | 38 } else { |
40 future = compiler.init(main); | 39 await compiler.init(main); |
41 } | 40 } |
42 return future.then((_) => compiler); | 41 return compiler; |
43 } | 42 } |
44 | 43 |
45 void expectHasBody(compiler, ElementX element) { | 44 void expectHasBody(compiler, ElementX element) { |
46 var node = element.parseNode(compiler.parsingContext); | 45 var node = element.parseNode(compiler.parsingContext); |
47 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 46 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
48 Expect.isNotNull(node.body); | 47 Expect.isNotNull(node.body); |
49 // If the element has a body it is either a Block or a Return statement, | 48 // If the element has a body it is either a Block or a Return statement, |
50 // both with different begin and end tokens. | 49 // both with different begin and end tokens. |
51 Expect.isTrue(node.body is Block || node.body is Return); | 50 Expect.isTrue(node.body is Block || node.body is Return); |
52 Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken()); | 51 Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken()); |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 await testPatchNonFunction(); | 1172 await testPatchNonFunction(); |
1174 | 1173 |
1175 await testPatchAndSelector(); | 1174 await testPatchAndSelector(); |
1176 | 1175 |
1177 await testEffectiveTarget(); | 1176 await testEffectiveTarget(); |
1178 | 1177 |
1179 await testAnalyzeAllInjectedMembers(); | 1178 await testAnalyzeAllInjectedMembers(); |
1180 await testTypecheckPatchedMembers(); | 1179 await testTypecheckPatchedMembers(); |
1181 }); | 1180 }); |
1182 } | 1181 } |
OLD | NEW |