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

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

Issue 594843003: Introduce LibraryUpdater. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Test edge cases. Created 6 years, 2 months 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/compiler_test_case.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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test of LibraryUpdater.
6 library trydart.library_updater_test;
7
8 import 'dart:convert' show
9 UTF8;
10
11 import 'package:dart2js_incremental/library_updater.dart' show
12 LibraryUpdater,
13 Update;
14
15 import 'package:compiler/implementation/elements/elements.dart' show
16 LibraryElement;
17
18 import 'compiler_test_case.dart';
19
20 void nolog(_) {}
21
22 class LibraryUpdaterTestCase extends CompilerTestCase {
23 final String newSource;
24
25 final bool expectedCanReuse;
26
27 final List<String> expectedUpdates;
28
29 LibraryUpdaterTestCase(
30 String source,
31 this.newSource,
32 this.expectedCanReuse,
Johnni Winther 2014/09/29 09:37:57 Change these to named arguments.
ahe 2014/09/29 11:44:42 I really wish we had mandatory named arguments. I
33 this.expectedUpdates)
34 : super(source);
35
36 Future run() => mainApp.then((LibraryElement library) {
37 LibraryUpdater updater =
38 new LibraryUpdater(this.compiler, null, scriptUri, nolog, nolog);
39 bool actualCanReuse =
40 updater.canReuseLibrary(library, UTF8.encode(newSource));
41 Expect.equals(expectedCanReuse, actualCanReuse);
42
43 Expect.setEquals(
44 expectedUpdates.toSet(),
45 updater.updates.map((Update update) => update.before.name).toSet());
46 });
47
48 String toString() => 'Before:\n$source\n\n\nAfter:\n$newSource';
49 }
50
51 void main() {
52 runTests(
53 [
54 // Only method body changed. Can be reused if 'main' is
55 // updated/patched.
56 new LibraryUpdaterTestCase(
57 'main() { print("Hello, World!"); }',
58 'main() { print("Hello, Brave New World!"); }',
59 true,
60 ['main']),
61
62 // Signature changed. Can't be reused.
63 new LibraryUpdaterTestCase(
64 'main() { print("Hello, World!"); }',
65 'void main() { print("Hello, World!"); }',
66 false,
67 []),
68
69 // Only whitespace changes. Can be reused; no updates/patches needed.
Johnni Winther 2014/09/29 09:34:42 Add a test for whitespace in the signature.
ahe 2014/09/29 11:44:42 Done.
70 new LibraryUpdaterTestCase(
71 'main(){print("Hello, World!");}',
72 'main() { print ( "Hello, World!" ) ; }',
73 true,
74 []),
75
76
77 // Arrow function changed to method body. Can be reused if 'main' is
78 // updated/patched.
79 new LibraryUpdaterTestCase(
80 'main() => null',
81 'main() { return null; }',
82 true,
83 ['main']),
84
85 // Empty body changed to contain a statement. Can be reused if 'main'
86 // is updated/patched.
87 new LibraryUpdaterTestCase(
88 'main() {}',
89 'main() { return null; }',
90 true,
91 ['main']),
92
93 // Empty body changed to arrow. Can be reused if 'main'
94 // is updated/patched.
95 new LibraryUpdaterTestCase(
96 'main() {}',
97 'main() => null;',
98 true,
99 ['main']),
100
101 // Arrow changed to empty body. Can be reused if 'main'
102 // is updated/patched.
103 new LibraryUpdaterTestCase(
104 'main() => null;',
105 'main() {}',
106 true,
107 ['main']),
108
109 // TODO(ahe): When supporting class members, test abstract methods.
110 ]
111 );
112 }
OLDNEW
« no previous file with comments | « dart/tests/try/poi/compiler_test_case.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698