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

Side by Side Diff: tests/compiler/dart2js/patch_test.dart

Issue 11052012: Patch signatures checked in resolver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check moved. Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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("../../../lib/compiler/implementation/leg.dart"); 5 #import("../../../lib/compiler/implementation/leg.dart");
6 #import("../../../lib/compiler/implementation/elements/elements.dart"); 6 #import("../../../lib/compiler/implementation/elements/elements.dart");
7 #import("../../../lib/compiler/implementation/tree/tree.dart"); 7 #import("../../../lib/compiler/implementation/tree/tree.dart");
8 #import("../../../lib/compiler/implementation/util/util.dart"); 8 #import("../../../lib/compiler/implementation/util/util.dart");
9 #import("mock_compiler.dart"); 9 #import("mock_compiler.dart");
10 #import("parser_helper.dart"); 10 #import("parser_helper.dart");
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 Expect.isFalse(element.isPatched && element.isPatch); 102 Expect.isFalse(element.isPatched && element.isPatch);
103 return element; 103 return element;
104 } 104 }
105 105
106 testPatchFunction() { 106 testPatchFunction() {
107 var compiler = applyPatch( 107 var compiler = applyPatch(
108 "external test();", 108 "external test();",
109 "patch test() { return 'string'; } "); 109 "patch test() { return 'string'; } ");
110 ensure(compiler, "test", compiler.coreLibrary.find, isPatched: true); 110 ensure(compiler, "test", compiler.coreLibrary.find, isPatched: true);
111 ensure(compiler, "test", compiler.coreLibrary.patch.find, isPatch: true); 111 ensure(compiler, "test", compiler.coreLibrary.patch.find, isPatch: true);
112
113 Expect.isTrue(compiler.warnings.isEmpty(),
114 "Unexpected warnings: ${compiler.warnings}");
115 Expect.isTrue(compiler.errors.isEmpty(),
116 "Unexpected errors: ${compiler.errors}");
112 } 117 }
113 118
114 testPatchMember() { 119 testPatchMember() {
115 var compiler = applyPatch( 120 var compiler = applyPatch(
116 """ 121 """
117 class Class { 122 class Class {
118 external String toString(); 123 external String toString();
119 } 124 }
120 """, 125 """,
121 """ 126 """
122 patch class Class { 127 patch class Class {
123 patch String toString() => 'string'; 128 patch String toString() => 'string';
124 } 129 }
125 """); 130 """);
126 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 131 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
127 isMethod: false, isPatched: true); 132 isMethod: false, isPatched: true);
128 container.parseNode(compiler); 133 container.parseNode(compiler);
129 ensure(compiler, "Class", compiler.coreLibrary.patch.find, 134 ensure(compiler, "Class", compiler.coreLibrary.patch.find,
130 isMethod: false, isPatch: true); 135 isMethod: false, isPatch: true);
131 136
132 ensure(compiler, "toString", container.lookupLocalMember, 137 ensure(compiler, "toString", container.lookupLocalMember,
133 isPatched: true); 138 isPatched: true);
134 ensure(compiler, "toString", container.patch.lookupLocalMember, 139 ensure(compiler, "toString", container.patch.lookupLocalMember,
135 isPatch: true); 140 isPatch: true);
141
142 Expect.isTrue(compiler.warnings.isEmpty(),
143 "Unexpected warnings: ${compiler.warnings}");
144 Expect.isTrue(compiler.errors.isEmpty(),
145 "Unexpected errors: ${compiler.errors}");
136 } 146 }
137 147
138 testPatchGetter() { 148 testPatchGetter() {
139 var compiler = applyPatch( 149 var compiler = applyPatch(
140 """ 150 """
141 class Class { 151 class Class {
142 external int get field; 152 external int get field;
143 } 153 }
144 """, 154 """,
145 """ 155 """
146 patch class Class { 156 patch class Class {
147 patch int get field => 5; 157 patch int get field => 5;
148 } 158 }
149 """); 159 """);
150 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 160 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
151 isPatched: true, isMethod: false); 161 isPatched: true, isMethod: false);
152 container.parseNode(compiler); 162 container.parseNode(compiler);
153 ensure(compiler, 163 ensure(compiler,
154 "field", 164 "field",
155 container.lookupLocalMember, 165 container.lookupLocalMember,
156 isGetter: true, 166 isGetter: true,
157 isPatched: true); 167 isPatched: true);
158 ensure(compiler, 168 ensure(compiler,
159 "field", 169 "field",
160 container.patch.lookupLocalMember, 170 container.patch.lookupLocalMember,
161 isGetter: true, 171 isGetter: true,
162 isPatch: true); 172 isPatch: true);
173
174 Expect.isTrue(compiler.warnings.isEmpty(),
175 "Unexpected warnings: ${compiler.warnings}");
176 Expect.isTrue(compiler.errors.isEmpty(),
177 "Unexpected errors: ${compiler.errors}");
163 } 178 }
164 179
165 testRegularMember() { 180 testRegularMember() {
166 var compiler = applyPatch( 181 var compiler = applyPatch(
167 """ 182 """
168 class Class { 183 class Class {
169 void regular() {} 184 void regular() {}
170 } 185 }
171 """, 186 """,
172 """ 187 """
173 patch class Class { 188 patch class Class {
174 } 189 }
175 """); 190 """);
176 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 191 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
177 isMethod: false, isPatched: true); 192 isMethod: false, isPatched: true);
178 container.parseNode(compiler); 193 container.parseNode(compiler);
179 ensure(compiler, "Class", compiler.coreLibrary.patch.find, 194 ensure(compiler, "Class", compiler.coreLibrary.patch.find,
180 isMethod: false, isPatch: true); 195 isMethod: false, isPatch: true);
181 196
182 ensure(compiler, "regular", container.lookupLocalMember); 197 ensure(compiler, "regular", container.lookupLocalMember);
183 ensure(compiler, "regular", container.patch.lookupLocalMember); 198 ensure(compiler, "regular", container.patch.lookupLocalMember);
199
200 Expect.isTrue(compiler.warnings.isEmpty(),
201 "Unexpected warnings: ${compiler.warnings}");
202 Expect.isTrue(compiler.errors.isEmpty(),
203 "Unexpected errors: ${compiler.errors}");
184 } 204 }
185 205
186 testGhostMember() { 206 testGhostMember() {
187 var compiler = applyPatch( 207 var compiler = applyPatch(
188 """ 208 """
189 class Class { 209 class Class {
190 } 210 }
191 """, 211 """,
192 """ 212 """
193 patch class Class { 213 patch class Class {
194 void ghost() {} 214 void ghost() {}
195 } 215 }
196 """); 216 """);
197 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 217 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
198 isMethod: false, isPatched: true); 218 isMethod: false, isPatched: true);
199 container.parseNode(compiler); 219 container.parseNode(compiler);
200 ensure(compiler, "Class", compiler.coreLibrary.patch.find, 220 ensure(compiler, "Class", compiler.coreLibrary.patch.find,
201 isMethod: false, isPatch: true); 221 isMethod: false, isPatch: true);
202 222
203 ensure(compiler, "ghost", container.lookupLocalMember, isFound: false); 223 ensure(compiler, "ghost", container.lookupLocalMember, isFound: false);
204 ensure(compiler, "ghost", container.patch.lookupLocalMember); 224 ensure(compiler, "ghost", container.patch.lookupLocalMember);
225
226 Expect.isTrue(compiler.warnings.isEmpty(),
227 "Unexpected warnings: ${compiler.warnings}");
228 Expect.isTrue(compiler.errors.isEmpty(),
229 "Unexpected errors: ${compiler.errors}");
205 } 230 }
206 231
207 testInjectFunction() { 232 testInjectFunction() {
208 var compiler = applyPatch( 233 var compiler = applyPatch(
209 "", 234 "",
210 "int _function() => 5;"); 235 "int _function() => 5;");
211 ensure(compiler, 236 ensure(compiler,
212 "_function", 237 "_function",
213 compiler.coreLibrary.find, 238 compiler.coreLibrary.find,
214 isFound: false); 239 isFound: false);
215 ensure(compiler, 240 ensure(compiler,
216 "_function", 241 "_function",
217 compiler.coreLibrary.patch.find); 242 compiler.coreLibrary.patch.find);
243
244 Expect.isTrue(compiler.warnings.isEmpty(),
245 "Unexpected warnings: ${compiler.warnings}");
246 Expect.isTrue(compiler.errors.isEmpty(),
247 "Unexpected errors: ${compiler.errors}");
248 }
249
250 testPatchSignatureCheck() {
251 var compiler = applyPatch(
252 """
253 class Class {
254 external String method1();
255 external void method2(String str);
256 external void method3(String s1);
257 external void method4([String str]);
258 external void method5({String str});
259 external void method6({String str});
260 external void method7([String s1]);
261 external void method8({String s1});
262 }
263 """,
264 """
265 patch class Class {
266 patch int method1() => 0;
267 patch void method2() {}
268 patch void method3(String s2) {}
269 patch void method4([String str, int i]) {}
270 patch void method5() {}
271 patch void method6([String str]) {}
272 patch void method7([String s2]) {}
273 patch void method8({String s2}) {}
274 }
275 """);
276 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
277 isMethod: false, isPatched: true);
278 container.ensureResolved(compiler);
279 container.parseNode(compiler);
280
281 compiler.resolver.resolveMethodElement(
282 ensure(compiler, "method1", container.lookupLocalMember,
283 isPatched: true));
284 Expect.isTrue(compiler.warnings.isEmpty(),
285 "Unexpected warnings: ${compiler.warnings}");
286 Expect.isFalse(compiler.errors.isEmpty());
287 print('method1:${compiler.errors}');
288
289 compiler.warnings.clear();
290 compiler.errors.clear();
291 compiler.resolver.resolveMethodElement(
292 ensure(compiler, "method2", container.lookupLocalMember,
293 isPatched: true));
294 Expect.isTrue(compiler.warnings.isEmpty(),
295 "Unexpected warnings: ${compiler.warnings}");
296 Expect.isFalse(compiler.errors.isEmpty());
297 print('method2:${compiler.errors}');
298
299 compiler.warnings.clear();
300 compiler.errors.clear();
301 compiler.resolver.resolveMethodElement(
302 ensure(compiler, "method3", container.lookupLocalMember,
303 isPatched: true));
304 Expect.isTrue(compiler.warnings.isEmpty(),
305 "Unexpected warnings: ${compiler.warnings}");
306 Expect.isFalse(compiler.errors.isEmpty());
307 print('method3:${compiler.errors}');
308
309 compiler.warnings.clear();
310 compiler.errors.clear();
311 compiler.resolver.resolveMethodElement(
312 ensure(compiler, "method4", container.lookupLocalMember,
313 isPatched: true));
314 Expect.isTrue(compiler.warnings.isEmpty(),
315 "Unexpected warnings: ${compiler.warnings}");
316 Expect.isFalse(compiler.errors.isEmpty());
317 print('method4:${compiler.errors}');
318
319 compiler.warnings.clear();
320 compiler.errors.clear();
321 compiler.resolver.resolveMethodElement(
322 ensure(compiler, "method5", container.lookupLocalMember,
323 isPatched: true));
324 Expect.isTrue(compiler.warnings.isEmpty(),
325 "Unexpected warnings: ${compiler.warnings}");
326 Expect.isFalse(compiler.errors.isEmpty());
327 print('method5:${compiler.errors}');
328
329 compiler.warnings.clear();
330 compiler.errors.clear();
331 compiler.resolver.resolveMethodElement(
332 ensure(compiler, "method6", container.lookupLocalMember,
333 isPatched: true));
334 Expect.isTrue(compiler.warnings.isEmpty(),
335 "Unexpected warnings: ${compiler.warnings}");
336 Expect.isFalse(compiler.errors.isEmpty());
337 print('method6:${compiler.errors}');
338
339 compiler.warnings.clear();
340 compiler.errors.clear();
341 compiler.resolver.resolveMethodElement(
342 ensure(compiler, "method7", container.lookupLocalMember,
343 isPatched: true));
344 Expect.isTrue(compiler.warnings.isEmpty(),
345 "Unexpected warnings: ${compiler.warnings}");
346 Expect.isFalse(compiler.errors.isEmpty());
347 print('method7:${compiler.errors}');
348
349 compiler.warnings.clear();
350 compiler.errors.clear();
351 compiler.resolver.resolveMethodElement(
352 ensure(compiler, "method8", container.lookupLocalMember,
353 isPatched: true));
354 Expect.isTrue(compiler.warnings.isEmpty(),
355 "Unexpected warnings: ${compiler.warnings}");
356 Expect.isFalse(compiler.errors.isEmpty());
357 print('method8:${compiler.errors}');
218 } 358 }
219 359
220 main() { 360 main() {
221 testPatchFunction(); 361 testPatchFunction();
222 testPatchMember(); 362 testPatchMember();
223 testPatchGetter(); 363 testPatchGetter();
224 testRegularMember(); 364 testRegularMember();
225 testGhostMember(); 365 testGhostMember();
226 testInjectFunction(); 366 testInjectFunction();
367 testPatchSignatureCheck();
227 } 368 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698