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

Unified Diff: dart/tests/try/web/incremental_compilation_update_test.dart

Issue 654523003: Handle top-level tear offs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated try.status. 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 side-by-side diff with in-line comments
Download patch
Index: dart/tests/try/web/incremental_compilation_update_test.dart
diff --git a/dart/tests/try/web/incremental_compilation_update_test.dart b/dart/tests/try/web/incremental_compilation_update_test.dart
index 4c043edf50932007aaaaaf678e527121b178325d..991fbbe8bcce7a7110b99d93a3fd185fa024ab47 100644
--- a/dart/tests/try/web/incremental_compilation_update_test.dart
+++ b/dart/tests/try/web/incremental_compilation_update_test.dart
@@ -20,44 +20,139 @@ import 'web_compiler_test_case.dart' show
WebCompilerTestCase,
WebInputProvider;
-void main() => asyncTest(() {
+import 'program_result.dart';
+
+const List<List<ProgramResult>> tests = const <List<ProgramResult>>[
+ // Basic hello-world test.
+ const <ProgramResult>[
+ const ProgramResult(
+ "main() { print('Hello, World!'); }",
+ const <String> ['Hello, World!']),
+ const ProgramResult(
+ "main() { print('Hello, Brave New World!'); }",
+ const <String> ['Hello, Brave New World!']),
+ ],
+
+ // Test that the test framework handles more than one update.
+ const <ProgramResult>[
+ const ProgramResult(
+ "main() { print('Hello darkness, my old friend'); }",
+ const <String> ['Hello darkness, my old friend']),
+ const ProgramResult(
+ "main() { print('I\\'ve come to talk with you again'); }",
+ const <String> ['I\'ve come to talk with you again']),
+ const ProgramResult(
+ "main() { print('Because a vision softly creeping'); }",
+ const <String> ['Because a vision softly creeping']),
+ ],
+
+ // Test that that isolate support works.
+ const <ProgramResult>[
+ const ProgramResult(
+ "main(arguments) { print('Hello, Isolated World!'); }",
+ const <String> ['Hello, Isolated World!']),
+ const ProgramResult(
+ "main(arguments) { print(arguments); }",
+ const <String> ['[]']),
+ ],
+
+ // Test that a stored closure changes behavior when updated.
+ const <ProgramResult>[
+ const ProgramResult(
+ r"""
+var closure;
+
+foo(a, [b = 'b']) {
+ print('$a $b');
+}
+
+main() {
+ if (closure == null) {
+ print('[closure] is null.');
+ closure = foo;
+ }
+ closure('a');
+ closure('a', 'c');
+}
+""",
+ const <String> ['[closure] is null.', 'a b', 'a c']),
+ const ProgramResult(
+ r"""
+var closure;
+
+foo(a, [b = 'b']) {
+ print('$b $a');
+}
+
+main() {
+ if (closure == null) {
+ print('[closure] is null.');
+ closure = foo;
+ }
+ closure('a');
+ closure('a', 'c');
+}
+""",
+ const <String> ['b a', 'c a']),
+ ],
+];
+
+
+void main() {
listener.start();
+ return asyncTest(() => Future.forEach(tests, compileAndRun));
+}
+
+Future compileAndRun(List<ProgramResult> programs) {
+ var status = new DivElement();
+ document.body.append(status);
+
IFrameElement iframe =
appendIFrame(
'/root_dart/tests/try/web/incremental_compilation_update.html',
document.body)
- ..style.width = '90vw'
- ..style.height = '90vh';
+ ..style.width = '100%'
+ ..style.height = '600px';
return listener.expect('iframe-ready').then((_) {
- WebCompilerTestCase test =
- new WebCompilerTestCase("main() { print('Hello, World!'); }");
+ ProgramResult program = programs.first;
+ status.append(new PreElement()..appendText(program.code));
+ status.style.color = 'orange';
+ WebCompilerTestCase test = new WebCompilerTestCase(program.code);
return test.run().then((String jsCode) {
- var objectUrl =
- Url.createObjectUrl(new Blob([jsCode], 'application/javascript'));
-
- iframe.contentWindow.postMessage(['add-script', objectUrl], '*');
- return listener.expect(['Hello, World!', 'iframe-dart-main-done']).then(
- (_) {
- WebInputProvider inputProvider =
- test.incrementalCompiler.inputProvider;
- Uri uri = test.scriptUri.resolve('?v2');
- inputProvider.cachedSources[uri] = new Future.value(
- "main() { print('Hello, Brave New World!'); }");
- Future future = test.incrementalCompiler.compileUpdates(
- {test.scriptUri: uri});
- return future.then((String update) {
- iframe.contentWindow.postMessage(['apply-update', update], '*');
-
- return listener.expect(
- ['Hello, Brave New World!',
- 'iframe-dart-updated-main-done']);
- });
- });
+ status.style.color = 'red';
+ var objectUrl =
+ Url.createObjectUrl(new Blob([jsCode], 'application/javascript'));
+
+ iframe.contentWindow.postMessage(['add-script', objectUrl], '*');
+ Future future =
+ listener.expect(program.messagesWith('iframe-dart-main-done'));
+ return future.then((_) {
+ int version = 2;
+ return Future.forEach(programs.skip(1), (ProgramResult program) {
+
+ status.append(new PreElement()..appendText(program.code));
+
+ WebInputProvider inputProvider =
+ test.incrementalCompiler.inputProvider;
+ Uri uri = test.scriptUri.resolve('?v${version++}');
+ inputProvider.cachedSources[uri] = new Future.value(program.code);
+ Future future = test.incrementalCompiler.compileUpdates(
+ {test.scriptUri: uri});
+ return future.then((String update) {
+ iframe.contentWindow.postMessage(['apply-update', update], '*');
+
+ return listener.expect(
+ program.messagesWith('iframe-dart-updated-main-done'));
+ });
+ });
+ });
});
}).then((_) {
+ status.style.color = 'limegreen';
+
// Remove the iframe to work around a bug in test.dart.
iframe.remove();
});
-});
+}

Powered by Google App Engine
This is Rietveld 408576698