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'; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 159 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
160 Expect.isTrue( | 160 Expect.isTrue( |
161 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 161 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
162 | 162 |
163 Expect.equals(1, origin.metadata.length, | 163 Expect.equals(1, origin.metadata.length, |
164 "Unexpected origin metadata: ${origin.metadata}."); | 164 "Unexpected origin metadata: ${origin.metadata}."); |
165 Expect.equals(3, patch.metadata.length, | 165 Expect.equals(3, patch.metadata.length, |
166 "Unexpected patch metadata: ${patch.metadata}."); | 166 "Unexpected patch metadata: ${patch.metadata}."); |
167 } | 167 } |
168 | 168 |
| 169 Future testPatchFunctionGeneric() async { |
| 170 var compiler = await applyPatch( |
| 171 "external T test<T>();", "@patch T test<T>() { return null; } "); |
| 172 Element origin = ensure( |
| 173 compiler, "test", compiler.commonElements.coreLibrary.find, |
| 174 expectIsPatched: true, checkHasBody: true); |
| 175 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, |
| 176 expectIsPatch: true, checkHasBody: true); |
| 177 compiler.resolver.resolve(origin); |
| 178 |
| 179 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 180 Expect.isTrue( |
| 181 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 182 Expect.isTrue( |
| 183 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 184 } |
| 185 |
| 186 Future testPatchFunctionGenericExtraTypeVariable() async { |
| 187 var compiler = await applyPatch( |
| 188 "external T test<T>();", "@patch T test<T, S>() { return null; } "); |
| 189 Element origin = ensure( |
| 190 compiler, "test", compiler.commonElements.coreLibrary.find, |
| 191 expectIsPatched: true, checkHasBody: true); |
| 192 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, |
| 193 expectIsPatch: true, checkHasBody: true); |
| 194 compiler.resolver.resolve(origin); |
| 195 |
| 196 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 197 Expect.isTrue( |
| 198 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 199 Expect.equals(1, collector.errors.length); |
| 200 Expect.isTrue(collector.errors.first.message.kind == |
| 201 MessageKind.PATCH_TYPE_VARIABLES_MISMATCH); |
| 202 } |
| 203 |
| 204 Future testPatchFunctionGenericDifferentNames() async { |
| 205 var compiler = await applyPatch( |
| 206 "external T test<T, S>();", "@patch T test<S, T>() { return null; } "); |
| 207 Element origin = ensure( |
| 208 compiler, "test", compiler.commonElements.coreLibrary.find, |
| 209 expectIsPatched: true, checkHasBody: true); |
| 210 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, |
| 211 expectIsPatch: true, checkHasBody: true); |
| 212 compiler.resolver.resolve(origin); |
| 213 |
| 214 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 215 Expect.isTrue( |
| 216 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 217 Expect.equals(1, collector.errors.length); |
| 218 Expect.isTrue(collector.errors.first.message.kind == |
| 219 MessageKind.PATCH_TYPE_VARIABLES_MISMATCH); |
| 220 } |
| 221 |
169 Future testPatchVersioned() async { | 222 Future testPatchVersioned() async { |
170 String fullPatch = "test(){return 'string';}"; | 223 String fullPatch = "test(){return 'string';}"; |
171 String lazyPatch = "test(){return 'new and improved string';}"; | 224 String lazyPatch = "test(){return 'new and improved string';}"; |
172 | 225 |
173 String patchSource = """ | 226 String patchSource = """ |
174 @patch_full $fullPatch | 227 @patch_full $fullPatch |
175 @patch_lazy $lazyPatch | 228 @patch_lazy $lazyPatch |
176 """; | 229 """; |
177 | 230 |
178 Future test(String patchVersion, | 231 Future test(String patchVersion, |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 compareWarningKinds( | 1132 compareWarningKinds( |
1080 patchText, [MessageKind.NOT_ASSIGNABLE], collector.warnings); | 1133 patchText, [MessageKind.NOT_ASSIGNABLE], collector.warnings); |
1081 } | 1134 } |
1082 | 1135 |
1083 main() { | 1136 main() { |
1084 asyncTest(() async { | 1137 asyncTest(() async { |
1085 await testPatchConstructor(); | 1138 await testPatchConstructor(); |
1086 await testPatchRedirectingConstructor(); | 1139 await testPatchRedirectingConstructor(); |
1087 await testPatchFunction(); | 1140 await testPatchFunction(); |
1088 await testPatchFunctionMetadata(); | 1141 await testPatchFunctionMetadata(); |
| 1142 await testPatchFunctionGeneric(); |
| 1143 await testPatchFunctionGenericExtraTypeVariable(); |
| 1144 await testPatchFunctionGenericDifferentNames(); |
1089 await testPatchMember(); | 1145 await testPatchMember(); |
1090 await testPatchGetter(); | 1146 await testPatchGetter(); |
1091 await testRegularMember(); | 1147 await testRegularMember(); |
1092 await testInjectedMember(); | 1148 await testInjectedMember(); |
1093 await testInjectedPublicMember(); | 1149 await testInjectedPublicMember(); |
1094 await testInjectedFunction(); | 1150 await testInjectedFunction(); |
1095 await testInjectedPublicFunction(); | 1151 await testInjectedPublicFunction(); |
1096 await testPatchSignatureCheck(); | 1152 await testPatchSignatureCheck(); |
1097 | 1153 |
1098 await testPatchVersioned(); | 1154 await testPatchVersioned(); |
(...skipping 17 matching lines...) Expand all Loading... |
1116 await testPatchNonFunction(); | 1172 await testPatchNonFunction(); |
1117 | 1173 |
1118 await testPatchAndSelector(); | 1174 await testPatchAndSelector(); |
1119 | 1175 |
1120 await testEffectiveTarget(); | 1176 await testEffectiveTarget(); |
1121 | 1177 |
1122 await testAnalyzeAllInjectedMembers(); | 1178 await testAnalyzeAllInjectedMembers(); |
1123 await testTypecheckPatchedMembers(); | 1179 await testTypecheckPatchedMembers(); |
1124 }); | 1180 }); |
1125 } | 1181 } |
OLD | NEW |