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

Side by Side Diff: dart/tests/try/poi/library_updater_test.dart

Issue 789873003: Update unit tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years 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/tests/try/poi/apply_updates_test.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 // Test of LibraryUpdater (one compilation unit per library). 5 // Test of LibraryUpdater (one compilation unit per library).
6 library trydart.library_updater_test; 6 library trydart.library_updater_test;
7 7
8 import 'dart:convert' show
9 UTF8;
10
11 import 'package:dart2js_incremental/library_updater.dart' show 8 import 'package:dart2js_incremental/library_updater.dart' show
12 IncrementalCompilerContext, 9 IncrementalCompilerContext,
13 LibraryUpdater, 10 LibraryUpdater,
14 Update; 11 Update;
15 12
13 import 'package:compiler/src/dart2jslib.dart' show
14 Script;
15
16 import 'package:compiler/src/source_file.dart' show
17 StringSourceFile;
18
16 import 'compiler_test_case.dart'; 19 import 'compiler_test_case.dart';
17 20
18 void nolog(_) {} 21 void nolog(_) {}
19 22
23 Script newScriptFrom(LibraryElement library, String newSource) {
24 Script script = library.entryCompilationUnit.script;
25 return script.copyWithFile(
26 new StringSourceFile(script.file.filename, newSource));
27 }
28
20 class LibraryUpdaterTestCase extends CompilerTestCase { 29 class LibraryUpdaterTestCase extends CompilerTestCase {
21 final String newSource; 30 final String newSource;
22 31
23 final bool expectedCanReuse; 32 final bool expectedCanReuse;
24 33
25 final List<String> expectedUpdates; 34 final List<String> expectedUpdates;
26 35
27 LibraryUpdaterTestCase( 36 LibraryUpdaterTestCase(
28 {String before, 37 {String before,
29 String after, 38 String after,
30 bool canReuse, 39 bool canReuse,
31 List<String> updates}) 40 List<String> updates})
32 : this.newSource = after, 41 : this.newSource = after,
33 this.expectedCanReuse = canReuse, 42 this.expectedCanReuse = canReuse,
34 this.expectedUpdates = updates, 43 this.expectedUpdates = updates,
35 super(before); 44 super(before);
36 45
37 Future run() => loadMainApp().then((LibraryElement library) { 46 Future run() => loadMainApp().then((LibraryElement library) {
38 var context = new IncrementalCompilerContext(); 47 var context = new IncrementalCompilerContext();
39 LibraryUpdater updater = 48 LibraryUpdater updater =
40 new LibraryUpdater(this.compiler, null, nolog, nolog, context); 49 new LibraryUpdater(this.compiler, null, nolog, nolog, context);
41 context.registerUriWithUpdates([scriptUri]); 50 context.registerUriWithUpdates([scriptUri]);
42 bool actualCanReuse = 51 bool actualCanReuse =
43 updater.canReuseLibrary(library, UTF8.encode(newSource)); 52 updater.canReuseLibrary(
53 library, <Script>[newScriptFrom(library, newSource)]);
44 Expect.equals(expectedCanReuse, actualCanReuse); 54 Expect.equals(expectedCanReuse, actualCanReuse);
45 55
46 Expect.setEquals( 56 Expect.setEquals(
47 expectedUpdates.toSet(), 57 expectedUpdates.toSet(),
48 updater.updates.map(nameOfUpdate).toSet()); 58 updater.updates.map(nameOfUpdate).toSet());
49 }); 59 });
50 60
51 String toString() => 'Before:\n$source\n\n\nAfter:\n$newSource'; 61 String toString() => 'Before:\n$source\n\n\nAfter:\n$newSource';
52 } 62 }
53 63
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 new LibraryUpdaterTestCase( 131 new LibraryUpdaterTestCase(
122 before: 'main() => null;', 132 before: 'main() => null;',
123 after: 'main() {}', 133 after: 'main() {}',
124 canReuse: true, 134 canReuse: true,
125 updates: ['main']), 135 updates: ['main']),
126 136
127 // TODO(ahe): When supporting class members, test abstract methods. 137 // TODO(ahe): When supporting class members, test abstract methods.
128 ] 138 ]
129 ); 139 );
130 } 140 }
OLDNEW
« no previous file with comments | « dart/tests/try/poi/apply_updates_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698