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

Side by Side Diff: tests/utils/dummy_compiler_test.dart

Issue 14690009: Make Completers asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Smoke test of the dart2js compiler API. 5 // Smoke test of the dart2js compiler API.
6 library dummy_compiler; 6 library dummy_compiler;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
11 import '../../sdk/lib/_internal/compiler/compiler.dart'; 11 import '../../sdk/lib/_internal/compiler/compiler.dart';
12 12
13 Future<String> provider(Uri uri) { 13 Future<String> provider(Uri uri) {
14 Completer<String> completer = new Completer<String>();
15 String source; 14 String source;
16 if (uri.scheme == "main") { 15 if (uri.scheme == "main") {
17 source = "main() {}"; 16 source = "main() {}";
18 } else if (uri.scheme == "lib") { 17 } else if (uri.scheme == "lib") {
19 if (uri.path.endsWith("/core.dart")) { 18 if (uri.path.endsWith("/core.dart")) {
20 source = """library core; 19 source = """library core;
21 class Object { 20 class Object {
22 operator==(other) {} 21 operator==(other) {}
23 } 22 }
24 class Type {} 23 class Type {}
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 source = 'library jshelper; class JSInvocationMirror {} ' 72 source = 'library jshelper; class JSInvocationMirror {} '
74 'class ConstantMap {} class TypeImpl {}'; 73 'class ConstantMap {} class TypeImpl {}';
75 } else if (uri.path.endsWith('isolate_helper.dart')) { 74 } else if (uri.path.endsWith('isolate_helper.dart')) {
76 source = 'library isolatehelper; class _WorkerStub {}'; 75 source = 'library isolatehelper; class _WorkerStub {}';
77 } else { 76 } else {
78 source = "library lib;"; 77 source = "library lib;";
79 } 78 }
80 } else { 79 } else {
81 throw "unexpected URI $uri"; 80 throw "unexpected URI $uri";
82 } 81 }
83 completer.complete(source); 82 return new Future.value(source);
84 return completer.future;
85 } 83 }
86 84
87 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { 85 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
88 if (uri == null) { 86 if (uri == null) {
89 print('$kind: $message'); 87 print('$kind: $message');
90 } else { 88 } else {
91 print('$uri:$begin:$end: $kind: $message'); 89 print('$uri:$begin:$end: $kind: $message');
92 } 90 }
93 } 91 }
94 92
95 main() { 93 main() {
96 Future<String> result = 94 Future<String> result =
97 compile(new Uri.fromComponents(scheme: 'main'), 95 compile(new Uri.fromComponents(scheme: 'main'),
98 new Uri.fromComponents(scheme: 'lib', path: '/'), 96 new Uri.fromComponents(scheme: 'lib', path: '/'),
99 new Uri.fromComponents(scheme: 'package', path: '/'), 97 new Uri.fromComponents(scheme: 'package', path: '/'),
100 provider, handler); 98 provider, handler);
101 result.then((String code) { 99 result.then((String code) {
102 if (code == null) { 100 if (code == null) {
103 throw 'Compilation failed'; 101 throw 'Compilation failed';
104 } 102 }
105 }, onError: (e) { 103 }, onError: (e) {
106 throw 'Compilation failed'; 104 throw 'Compilation failed';
107 }); 105 });
108 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698