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 // Test of LibraryUpdater. | 5 // Test of LibraryUpdater. |
6 library trydart.library_updater_test; | 6 library trydart.library_updater_test; |
7 | 7 |
8 import 'dart:convert' show | 8 import 'dart:convert' show |
9 UTF8; | 9 UTF8; |
10 | 10 |
11 import 'package:dart2js_incremental/library_updater.dart' show | 11 import 'package:dart2js_incremental/library_updater.dart' show |
| 12 IncrementalCompilerContext, |
12 LibraryUpdater, | 13 LibraryUpdater, |
13 Update; | 14 Update; |
14 | 15 |
15 import 'compiler_test_case.dart'; | 16 import 'compiler_test_case.dart'; |
16 | 17 |
17 void nolog(_) {} | 18 void nolog(_) {} |
18 | 19 |
19 class LibraryUpdaterTestCase extends CompilerTestCase { | 20 class LibraryUpdaterTestCase extends CompilerTestCase { |
20 final String newSource; | 21 final String newSource; |
21 | 22 |
22 final bool expectedCanReuse; | 23 final bool expectedCanReuse; |
23 | 24 |
24 final List<String> expectedUpdates; | 25 final List<String> expectedUpdates; |
25 | 26 |
26 LibraryUpdaterTestCase( | 27 LibraryUpdaterTestCase( |
27 {String before, | 28 {String before, |
28 String after, | 29 String after, |
29 bool canReuse, | 30 bool canReuse, |
30 List<String> updates}) | 31 List<String> updates}) |
31 : this.newSource = after, | 32 : this.newSource = after, |
32 this.expectedCanReuse = canReuse, | 33 this.expectedCanReuse = canReuse, |
33 this.expectedUpdates = updates, | 34 this.expectedUpdates = updates, |
34 super(before); | 35 super(before); |
35 | 36 |
36 Future run() => loadMainApp().then((LibraryElement library) { | 37 Future run() => loadMainApp().then((LibraryElement library) { |
| 38 var context = new IncrementalCompilerContext(); |
37 LibraryUpdater updater = | 39 LibraryUpdater updater = |
38 new LibraryUpdater(this.compiler, null, scriptUri, nolog, nolog); | 40 new LibraryUpdater(this.compiler, null, nolog, nolog, context); |
| 41 context.registerUriWithUpdates([scriptUri]); |
39 bool actualCanReuse = | 42 bool actualCanReuse = |
40 updater.canReuseLibrary(library, UTF8.encode(newSource)); | 43 updater.canReuseLibrary(library, UTF8.encode(newSource)); |
41 Expect.equals(expectedCanReuse, actualCanReuse); | 44 Expect.equals(expectedCanReuse, actualCanReuse); |
42 | 45 |
43 Expect.setEquals( | 46 Expect.setEquals( |
44 expectedUpdates.toSet(), | 47 expectedUpdates.toSet(), |
45 updater.updates.map(nameOfUpdate).toSet()); | 48 updater.updates.map(nameOfUpdate).toSet()); |
46 }); | 49 }); |
47 | 50 |
48 String toString() => 'Before:\n$source\n\n\nAfter:\n$newSource'; | 51 String toString() => 'Before:\n$source\n\n\nAfter:\n$newSource'; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 new LibraryUpdaterTestCase( | 121 new LibraryUpdaterTestCase( |
119 before: 'main() => null;', | 122 before: 'main() => null;', |
120 after: 'main() {}', | 123 after: 'main() {}', |
121 canReuse: true, | 124 canReuse: true, |
122 updates: ['main']), | 125 updates: ['main']), |
123 | 126 |
124 // TODO(ahe): When supporting class members, test abstract methods. | 127 // TODO(ahe): When supporting class members, test abstract methods. |
125 ] | 128 ] |
126 ); | 129 ); |
127 } | 130 } |
OLD | NEW |