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 22 matching lines...) Expand all Loading... |
33 import '../poi/compiler_test_case.dart' show | 33 import '../poi/compiler_test_case.dart' show |
34 CompilerTestCase; | 34 CompilerTestCase; |
35 | 35 |
36 import 'package:compiler/src/elements/elements.dart' show | 36 import 'package:compiler/src/elements/elements.dart' show |
37 Element, | 37 Element, |
38 LibraryElement; | 38 LibraryElement; |
39 | 39 |
40 import 'package:compiler/src/dart2jslib.dart' show | 40 import 'package:compiler/src/dart2jslib.dart' show |
41 Compiler; | 41 Compiler; |
42 | 42 |
| 43 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
| 44 IncrementalCompilationFailed; |
| 45 |
43 import 'program_result.dart'; | 46 import 'program_result.dart'; |
44 | 47 |
45 const int TIMEOUT = 100; | 48 const int TIMEOUT = 100; |
46 | 49 |
47 const List<EncodedResult> tests = const <EncodedResult>[ | 50 const List<EncodedResult> tests = const <EncodedResult>[ |
48 // Basic hello-world test. | 51 // Basic hello-world test. |
49 const EncodedResult( | 52 const EncodedResult( |
50 const [ | 53 const [ |
51 "main() { print('Hello, ", | 54 "main() { print('Hello, ", |
52 const ["", "Brave New "], | 55 const ["", "Brave New "], |
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 listener.expect(program.messagesWith('iframe-dart-main-done')); | 1750 listener.expect(program.messagesWith('iframe-dart-main-done')); |
1748 return future.then((_) { | 1751 return future.then((_) { |
1749 int version = 2; | 1752 int version = 2; |
1750 return Future.forEach(programs.skip(1), (ProgramResult program) { | 1753 return Future.forEach(programs.skip(1), (ProgramResult program) { |
1751 | 1754 |
1752 status.append(new HeadingElement.h2()..appendText("Update:")); | 1755 status.append(new HeadingElement.h2()..appendText("Update:")); |
1753 status.append(numberedLines(program.code)); | 1756 status.append(numberedLines(program.code)); |
1754 | 1757 |
1755 WebInputProvider inputProvider = | 1758 WebInputProvider inputProvider = |
1756 test.incrementalCompiler.inputProvider; | 1759 test.incrementalCompiler.inputProvider; |
1757 Uri uri = test.scriptUri.resolve('?v${version++}'); | 1760 Uri base = test.scriptUri; |
1758 inputProvider.cachedSources[uri] = new Future.value(program.code); | 1761 Map<String, String> code = program.code is String |
| 1762 ? { 'main.dart': program.code } |
| 1763 : program.code; |
| 1764 Map<Uri, Uri> uriMap = <Uri, Uri>{}; |
| 1765 for (String name in code.keys) { |
| 1766 Uri uri = base.resolve('$name?v${version++}'); |
| 1767 inputProvider.cachedSources[uri] = new Future.value(code[name]); |
| 1768 uriMap[base.resolve(name)] = uri; |
| 1769 } |
1759 Future future = test.incrementalCompiler.compileUpdates( | 1770 Future future = test.incrementalCompiler.compileUpdates( |
1760 {test.scriptUri: uri}, logVerbose: logger, logTime: logger); | 1771 uriMap, logVerbose: logger, logTime: logger); |
1761 future = future.catchError((error, trace) { | 1772 future = future.catchError((error, trace) { |
1762 String statusMessage; | 1773 String statusMessage; |
1763 Future result; | 1774 Future result; |
1764 if (program.compileUpdatesShouldThrow) { | 1775 if (program.compileUpdatesShouldThrow && |
| 1776 error is IncrementalCompilationFailed) { |
1765 statusMessage = "Expected error in compileUpdates."; | 1777 statusMessage = "Expected error in compileUpdates."; |
1766 result = null; | 1778 result = null; |
1767 } else { | 1779 } else { |
1768 statusMessage = "Unexpected error in compileUpdates."; | 1780 statusMessage = "Unexpected error in compileUpdates."; |
1769 result = new Future.error(error, trace); | 1781 result = new Future.error(error, trace); |
1770 } | 1782 } |
1771 status.append(new HeadingElement.h3()..appendText(statusMessage)); | 1783 status.append(new HeadingElement.h3()..appendText(statusMessage)); |
1772 return result; | 1784 return result; |
1773 }); | 1785 }); |
1774 return future.then((String update) { | 1786 return future.then((String update) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 position: absolute; | 1908 position: absolute; |
1897 left: 0px; | 1909 left: 0px; |
1898 width: 3em; | 1910 width: 3em; |
1899 text-align: right; | 1911 text-align: right; |
1900 background-color: lightgoldenrodyellow; | 1912 background-color: lightgoldenrodyellow; |
1901 } | 1913 } |
1902 '''); | 1914 '''); |
1903 style.type = 'text/css'; | 1915 style.type = 'text/css'; |
1904 return style; | 1916 return style; |
1905 } | 1917 } |
OLD | NEW |