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

Side by Side Diff: dart/tests/try/web/incremental_compilation_update_test.dart

Issue 713263003: Add test for removing static method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « dart/pkg/dart2js_incremental/lib/library_updater.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) 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 library trydart.incremental_compilation_update_test; 5 library trydart.incremental_compilation_update_test;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'dart:async' show 9 import 'dart:async' show
10 Future; 10 Future;
11 11
12 import 'package:async_helper/async_helper.dart' show 12 import 'package:async_helper/async_helper.dart' show
13 asyncTest; 13 asyncTest;
14 14
15 import 'package:try/src/interaction_manager.dart' show
16 splitLines;
17
15 import 'sandbox.dart' show 18 import 'sandbox.dart' show
16 appendIFrame, 19 appendIFrame,
17 listener; 20 listener;
18 21
19 import 'web_compiler_test_case.dart' show 22 import 'web_compiler_test_case.dart' show
20 WebCompilerTestCase, 23 WebCompilerTestCase,
21 WebInputProvider; 24 WebInputProvider;
22 25
23 import 'program_result.dart'; 26 import 'program_result.dart';
24 27
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 main() { 336 main() {
334 if (instance == null) { 337 if (instance == null) {
335 instance = new C(); 338 instance = new C();
336 } 339 }
337 instance.m(); 340 instance.m();
338 } 341 }
339 """, 342 """,
340 const <String> ['v2']), 343 const <String> ['v2']),
341 ], 344 ],
342 345
343 346 // Test that deleting a static method works.
344 347 const <ProgramResult>[
348 const ProgramResult(
349 """
350 class B {
351 static staticMethod() {
352 print('v1');
353 }
354 }
355 class C {
356 m() {
357 try {
358 B.staticMethod();
359 } catch (e) {
360 print('v2');
361 }
362 try {
363 // Ensure that noSuchMethod support is compiled. This test is not about
364 // adding new classes.
365 B.missingMethod();
366 print('bad');
367 } catch (e) {
368 }
369 }
370 }
371 var instance;
372 main() {
373 if (instance == null) {
374 instance = new C();
375 }
376 instance.m();
377 }
378 """,
379 const <String> ['v1']),
380 const ProgramResult(
381 """
382 class B {
383 }
384 class C {
385 m() {
386 try {
387 B.staticMethod();
388 } catch (e) {
389 print('v2');
390 }
391 try {
392 // Ensure that noSuchMethod support is compiled. This test is not about
393 // adding new classes.
394 B.missingMethod();
395 print('bad');
396 } catch (e) {
397 }
398 }
399 }
400 var instance;
401 main() {
402 if (instance == null) {
403 instance = new C();
404 }
405 instance.m();
406 }
407 """,
408 const <String> ['v2']),
409 ],
345 ]; 410 ];
346 411
347 void main() { 412 void main() {
348 listener.start(); 413 listener.start();
349 414
415 document.head.append(lineNumberStyle());
416
350 return asyncTest(() => Future.forEach(tests, compileAndRun)); 417 return asyncTest(() => Future.forEach(tests, compileAndRun));
351 } 418 }
352 419
353 Future compileAndRun(List<ProgramResult> programs) { 420 Future compileAndRun(List<ProgramResult> programs) {
354 var status = new DivElement(); 421 var status = new DivElement();
355 document.body.append(status); 422 document.body.append(status);
356 423
357 IFrameElement iframe = 424 IFrameElement iframe =
358 appendIFrame( 425 appendIFrame(
359 '/root_dart/tests/try/web/incremental_compilation_update.html', 426 '/root_dart/tests/try/web/incremental_compilation_update.html',
360 document.body) 427 document.body)
361 ..style.width = '100%' 428 ..style.width = '100%'
362 ..style.height = '600px'; 429 ..style.height = '600px';
363 430
364 return listener.expect('iframe-ready').then((_) { 431 return listener.expect('iframe-ready').then((_) {
365 ProgramResult program = programs.first; 432 ProgramResult program = programs.first;
366 status.append(new PreElement()..appendText(program.code)); 433
434
435 status.append(new HeadingElement.h2()..appendText("Full program:"));
436 status.append(numberedLines(program.code));
437
367 status.style.color = 'orange'; 438 status.style.color = 'orange';
368 WebCompilerTestCase test = new WebCompilerTestCase(program.code); 439 WebCompilerTestCase test = new WebCompilerTestCase(program.code);
369 return test.run().then((String jsCode) { 440 return test.run().then((String jsCode) {
370 status.style.color = 'red'; 441 status.style.color = 'red';
371 var objectUrl = 442 var objectUrl =
372 Url.createObjectUrl(new Blob([jsCode], 'application/javascript')); 443 Url.createObjectUrl(new Blob([jsCode], 'application/javascript'));
373 444
374 iframe.contentWindow.postMessage(['add-script', objectUrl], '*'); 445 iframe.contentWindow.postMessage(['add-script', objectUrl], '*');
375 Future future = 446 Future future =
376 listener.expect(program.messagesWith('iframe-dart-main-done')); 447 listener.expect(program.messagesWith('iframe-dart-main-done'));
377 return future.then((_) { 448 return future.then((_) {
378 int version = 2; 449 int version = 2;
379 return Future.forEach(programs.skip(1), (ProgramResult program) { 450 return Future.forEach(programs.skip(1), (ProgramResult program) {
380 451
381 status.append(new PreElement()..appendText(program.code)); 452 status.append(new HeadingElement.h2()..appendText("Update:"));
453 status.append(numberedLines(program.code));
382 454
383 WebInputProvider inputProvider = 455 WebInputProvider inputProvider =
384 test.incrementalCompiler.inputProvider; 456 test.incrementalCompiler.inputProvider;
385 Uri uri = test.scriptUri.resolve('?v${version++}'); 457 Uri uri = test.scriptUri.resolve('?v${version++}');
386 inputProvider.cachedSources[uri] = new Future.value(program.code); 458 inputProvider.cachedSources[uri] = new Future.value(program.code);
387 Future future = test.incrementalCompiler.compileUpdates( 459 Future future = test.incrementalCompiler.compileUpdates(
388 {test.scriptUri: uri}, logVerbose: logger, logTime: logger); 460 {test.scriptUri: uri}, logVerbose: logger, logTime: logger);
389 return future.then((String update) { 461 return future.then((String update) {
390 print({'update': update}); 462 print({'update': update});
391 iframe.contentWindow.postMessage(['apply-update', update], '*'); 463 iframe.contentWindow.postMessage(['apply-update', update], '*');
(...skipping 14 matching lines...) Expand all
406 478
407 void logger(x) { 479 void logger(x) {
408 print(x); 480 print(x);
409 bool isCheckedMode = false; 481 bool isCheckedMode = false;
410 assert(isCheckedMode = true); 482 assert(isCheckedMode = true);
411 int timeout = isCheckedMode ? TIMEOUT * 2 : TIMEOUT; 483 int timeout = isCheckedMode ? TIMEOUT * 2 : TIMEOUT;
412 if (listener.elapsed > timeout) { 484 if (listener.elapsed > timeout) {
413 throw 'Test timed out.'; 485 throw 'Test timed out.';
414 } 486 }
415 } 487 }
488
489 Element numberedLines(String code) {
490 DivElement result = new DivElement();
491 result.classes.add("output");
492
493 for (String text in splitLines(code)) {
494 Element line = new PreElement()
495 ..appendText(text.trimRight())
496 ..classes.add("line");
497 result.append(line);
498 }
499
500 return result;
501 }
502
503
504 StyleElement lineNumberStyle() {
505 StyleElement style = new StyleElement()..appendText('''
506 h2 {
507 color: black;
508 }
509
510 .output {
511 padding: 0px;
512 counter-reset: line-number;
513 padding-bottom: 1em;
514 }
515
516 .line {
517 white-space: pre-wrap;
518 padding-left: 3.5em;
519 margin-top: 0;
520 margin-bottom: 0;
521 }
522
523 .line::before {
524 counter-increment: line-number;
525 content: counter(line-number) " ";
526 position: absolute;
527 left: 0px;
528 width: 3em;
529 text-align: right;
530 background-color: lightgoldenrodyellow;
531 }
532 ''');
533 style.type = 'text/css';
534 return style;
535 }
OLDNEW
« no previous file with comments | « dart/pkg/dart2js_incremental/lib/library_updater.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698