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 | 9 import 'package:compiler/src/diagnostics/messages.dart' show |
10 MessageKind; | 10 MessageKind; |
(...skipping 19 matching lines...) Expand all Loading... |
30 Map<String, String> core = <String, String>{'script': script}; | 30 Map<String, String> core = <String, String>{'script': script}; |
31 MockCompiler compiler = new MockCompiler.internal(coreSource: core, | 31 MockCompiler compiler = new MockCompiler.internal(coreSource: core, |
32 analyzeAll: analyzeAll, | 32 analyzeAll: analyzeAll, |
33 analyzeOnly: analyzeOnly, | 33 analyzeOnly: analyzeOnly, |
34 patchVersion: patchVersion); | 34 patchVersion: patchVersion); |
35 compiler.diagnosticHandler = createHandler(compiler, ''); | 35 compiler.diagnosticHandler = createHandler(compiler, ''); |
36 var uri = Uri.parse("patch:core"); | 36 var uri = Uri.parse("patch:core"); |
37 compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch"); | 37 compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch"); |
38 var future; | 38 var future; |
39 if (runCompiler) { | 39 if (runCompiler) { |
40 future = compiler.runCompiler(null, main); | 40 future = compiler.run(null, main); |
41 } else { | 41 } else { |
42 future = compiler.init(main); | 42 future = compiler.init(main); |
43 } | 43 } |
44 return future.then((_) => compiler); | 44 return future.then((_) => compiler); |
45 } | 45 } |
46 | 46 |
47 void expectHasBody(compiler, ElementX element) { | 47 void expectHasBody(compiler, ElementX element) { |
48 var node = element.parseNode(compiler.parsing); | 48 var node = element.parseNode(compiler.parsing); |
49 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 49 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
50 Expect.isNotNull(node.body); | 50 Expect.isNotNull(node.body); |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 Future testAnalyzeAllInjectedMembers() async { | 959 Future testAnalyzeAllInjectedMembers() async { |
960 Future expect(String patchText, [expectedWarnings]) async { | 960 Future expect(String patchText, [expectedWarnings]) async { |
961 if (expectedWarnings == null) expectedWarnings = []; | 961 if (expectedWarnings == null) expectedWarnings = []; |
962 if (expectedWarnings is! List) { | 962 if (expectedWarnings is! List) { |
963 expectedWarnings = <MessageKind>[expectedWarnings]; | 963 expectedWarnings = <MessageKind>[expectedWarnings]; |
964 } | 964 } |
965 | 965 |
966 var compiler = await applyPatch('', patchText, analyzeAll: true, | 966 var compiler = await applyPatch('', patchText, analyzeAll: true, |
967 analyzeOnly: true); | 967 analyzeOnly: true); |
968 compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')]; | 968 compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')]; |
969 await compiler.runCompiler(null); | 969 await compiler.run(null); |
970 compareWarningKinds(patchText, expectedWarnings, compiler.warnings); | 970 compareWarningKinds(patchText, expectedWarnings, compiler.warnings); |
971 } | 971 } |
972 | 972 |
973 await expect('String s = 0;', MessageKind.NOT_ASSIGNABLE); | 973 await expect('String s = 0;', MessageKind.NOT_ASSIGNABLE); |
974 await expect('void method() { String s = 0; }', MessageKind.NOT_ASSIGNABLE); | 974 await expect('void method() { String s = 0; }', MessageKind.NOT_ASSIGNABLE); |
975 await expect(''' | 975 await expect(''' |
976 class Class { | 976 class Class { |
977 String s = 0; | 977 String s = 0; |
978 } | 978 } |
979 ''', | 979 ''', |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 Future testTypecheckPatchedMembers() async { | 1031 Future testTypecheckPatchedMembers() async { |
1032 String originText = "external void method();"; | 1032 String originText = "external void method();"; |
1033 String patchText = """ | 1033 String patchText = """ |
1034 @patch void method() { | 1034 @patch void method() { |
1035 String s = 0; | 1035 String s = 0; |
1036 } | 1036 } |
1037 """; | 1037 """; |
1038 var compiler = await applyPatch(originText, patchText, | 1038 var compiler = await applyPatch(originText, patchText, |
1039 analyzeAll: true, analyzeOnly: true); | 1039 analyzeAll: true, analyzeOnly: true); |
1040 compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')]; | 1040 compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')]; |
1041 await compiler.runCompiler(null); | 1041 await compiler.run(null); |
1042 compareWarningKinds(patchText, | 1042 compareWarningKinds(patchText, |
1043 [MessageKind.NOT_ASSIGNABLE], compiler.warnings); | 1043 [MessageKind.NOT_ASSIGNABLE], compiler.warnings); |
1044 } | 1044 } |
1045 | 1045 |
1046 main() { | 1046 main() { |
1047 asyncTest(() async { | 1047 asyncTest(() async { |
1048 await testPatchConstructor(); | 1048 await testPatchConstructor(); |
1049 await testPatchRedirectingConstructor(); | 1049 await testPatchRedirectingConstructor(); |
1050 await testPatchFunction(); | 1050 await testPatchFunction(); |
1051 await testPatchFunctionMetadata(); | 1051 await testPatchFunctionMetadata(); |
(...skipping 27 matching lines...) Expand all Loading... |
1079 await testPatchNonFunction(); | 1079 await testPatchNonFunction(); |
1080 | 1080 |
1081 await testPatchAndSelector(); | 1081 await testPatchAndSelector(); |
1082 | 1082 |
1083 await testEffectiveTarget(); | 1083 await testEffectiveTarget(); |
1084 | 1084 |
1085 await testAnalyzeAllInjectedMembers(); | 1085 await testAnalyzeAllInjectedMembers(); |
1086 await testTypecheckPatchedMembers(); | 1086 await testTypecheckPatchedMembers(); |
1087 }); | 1087 }); |
1088 } | 1088 } |
OLD | NEW |