OLD | NEW |
---|---|
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' hide | 7 import 'dart:html' hide |
8 Element; | 8 Element; |
9 | 9 |
10 import 'dart:async' show | 10 import 'dart:async' show |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1652 const ProgramExpectation( | 1652 const ProgramExpectation( |
1653 const <String>['A(v2)', 'B(v2)', 'B(A(v2))', 'A(B(v2))']), | 1653 const <String>['A(v2)', 'B(v2)', 'B(A(v2))', 'A(B(v2))']), |
1654 ]), | 1654 ]), |
1655 | 1655 |
1656 const EncodedResult( | 1656 const EncodedResult( |
1657 r""" | 1657 r""" |
1658 ==> main.dart <== | 1658 ==> main.dart <== |
1659 library test.main; | 1659 library test.main; |
1660 | 1660 |
1661 part 'part.dart'; | 1661 part 'part.dart'; |
1662 ==> part.dart.patch <== | 1662 ==> part.dart.patch <== |
Johnni Winther
2014/12/19 12:17:33
Add blank lines around ==> ... <== lines.
ahe
2014/12/19 13:35:45
Done.
| |
1663 part of test.main; | 1663 part of test.main; |
1664 | 1664 |
1665 main() { | 1665 main() { |
1666 <<<<<<< | 1666 <<<<<<< |
1667 print('Hello, World!'); | 1667 print('Hello, World!'); |
1668 ======= | 1668 ======= |
1669 print('Hello, Brave New World!'); | 1669 print('Hello, Brave New World!'); |
1670 >>>>>>> | 1670 >>>>>>> |
1671 } | 1671 } |
1672 """, | 1672 """, |
1673 const [ | 1673 const [ |
1674 'Hello, World!', | 1674 'Hello, World!', |
1675 const ProgramExpectation( | 1675 'Hello, Brave New World!', |
1676 const <String>['Hello, Brave New World!'], | |
1677 // TODO(ahe): Shouldn't throw. | |
1678 compileUpdatesShouldThrow: true), | |
1679 ]), | 1676 ]), |
1680 ]; | 1677 ]; |
1681 | 1678 |
1682 void main() { | 1679 void main() { |
1683 listener.start(); | 1680 listener.start(); |
1684 | 1681 |
1685 document.head.append(lineNumberStyle()); | 1682 document.head.append(lineNumberStyle()); |
1686 | 1683 |
1687 summary = new SpanElement(); | 1684 summary = new SpanElement(); |
1688 document.body.append(new HeadingElement.h1() | 1685 document.body.append(new HeadingElement.h1() |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 ? { 'main.dart': program.code } | 1759 ? { 'main.dart': program.code } |
1763 : program.code; | 1760 : program.code; |
1764 Map<Uri, Uri> uriMap = <Uri, Uri>{}; | 1761 Map<Uri, Uri> uriMap = <Uri, Uri>{}; |
1765 for (String name in code.keys) { | 1762 for (String name in code.keys) { |
1766 Uri uri = base.resolve('$name?v${version++}'); | 1763 Uri uri = base.resolve('$name?v${version++}'); |
1767 inputProvider.cachedSources[uri] = new Future.value(code[name]); | 1764 inputProvider.cachedSources[uri] = new Future.value(code[name]); |
1768 uriMap[base.resolve(name)] = uri; | 1765 uriMap[base.resolve(name)] = uri; |
1769 } | 1766 } |
1770 Future future = test.incrementalCompiler.compileUpdates( | 1767 Future future = test.incrementalCompiler.compileUpdates( |
1771 uriMap, logVerbose: logger, logTime: logger); | 1768 uriMap, logVerbose: logger, logTime: logger); |
1769 bool compileUpdatesThrew = false; | |
1772 future = future.catchError((error, trace) { | 1770 future = future.catchError((error, trace) { |
1773 String statusMessage; | 1771 String statusMessage; |
1774 Future result; | 1772 Future result; |
1773 compileUpdatesThrew = true; | |
1775 if (program.compileUpdatesShouldThrow && | 1774 if (program.compileUpdatesShouldThrow && |
1776 error is IncrementalCompilationFailed) { | 1775 error is IncrementalCompilationFailed) { |
1777 statusMessage = "Expected error in compileUpdates."; | 1776 statusMessage = "Expected error in compileUpdates."; |
1778 result = null; | 1777 result = null; |
1779 } else { | 1778 } else { |
1780 statusMessage = "Unexpected error in compileUpdates."; | 1779 statusMessage = "Unexpected error in compileUpdates."; |
1781 result = new Future.error(error, trace); | 1780 result = new Future.error(error, trace); |
1782 } | 1781 } |
1783 status.append(new HeadingElement.h3()..appendText(statusMessage)); | 1782 status.append(new HeadingElement.h3()..appendText(statusMessage)); |
1784 return result; | 1783 return result; |
1785 }); | 1784 }); |
1786 return future.then((String update) { | 1785 return future.then((String update) { |
1787 if (program.compileUpdatesShouldThrow) { | 1786 if (program.compileUpdatesShouldThrow) { |
1788 Expect.isNull(update); | 1787 Expect.isTrue( |
1788 compileUpdatesThrew, | |
1789 "Expected an exception in compileUpdates"); | |
1790 Expect.isNull( update, "Expected update == null"); | |
1789 return null; | 1791 return null; |
1790 } | 1792 } |
1791 print({'update': update}); | 1793 print({'update': update}); |
1792 iframe.contentWindow.postMessage(['apply-update', update], '*'); | 1794 iframe.contentWindow.postMessage(['apply-update', update], '*'); |
1793 | 1795 |
1794 return listener.expect( | 1796 return listener.expect( |
1795 program.messagesWith('iframe-dart-updated-main-done')) | 1797 program.messagesWith('iframe-dart-updated-main-done')) |
1796 .then((_) { | 1798 .then((_) { |
1799 // TODO(ahe): Enable SerializeScopeTestCase for multiple | |
1800 // parts. | |
1801 if (program.code is! String) return null; | |
1797 return new SerializeScopeTestCase( | 1802 return new SerializeScopeTestCase( |
1798 program.code, test.incrementalCompiler.mainApp, | 1803 program.code, test.incrementalCompiler.mainApp, |
1799 test.incrementalCompiler.compiler).run(); | 1804 test.incrementalCompiler.compiler).run(); |
1800 }); | 1805 }); |
1801 }); | 1806 }); |
1802 }); | 1807 }); |
1803 }); | 1808 }); |
1804 }); | 1809 }); |
1805 }).then((_) { | 1810 }).then((_) { |
1806 status.style.color = 'limegreen'; | 1811 status.style.color = 'limegreen'; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1908 position: absolute; | 1913 position: absolute; |
1909 left: 0px; | 1914 left: 0px; |
1910 width: 3em; | 1915 width: 3em; |
1911 text-align: right; | 1916 text-align: right; |
1912 background-color: lightgoldenrodyellow; | 1917 background-color: lightgoldenrodyellow; |
1913 } | 1918 } |
1914 '''); | 1919 '''); |
1915 style.type = 'text/css'; | 1920 style.type = 'text/css'; |
1916 return style; | 1921 return style; |
1917 } | 1922 } |
OLD | NEW |