OLD | NEW |
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 // VMOptions= | 4 // VMOptions= |
5 // VMOptions=--print-object-histogram | 5 // VMOptions=--print-object-histogram |
6 | 6 |
7 // Smoke test of the dart2js compiler API. | 7 // Smoke test of the dart2js compiler API. |
8 library dummy_compiler; | 8 library dummy_compiler; |
9 | 9 |
10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import "package:async_helper/async_helper.dart"; |
11 | 12 |
12 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 13 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
13 | 14 |
14 Future<String> provider(Uri uri) { | 15 Future<String> provider(Uri uri) { |
15 String source; | 16 String source; |
16 if (uri.scheme == "main") { | 17 if (uri.scheme == "main") { |
17 source = "main() {}"; | 18 source = "main() {}"; |
18 } else if (uri.scheme == "lib") { | 19 } else if (uri.scheme == "lib") { |
19 if (uri.path.endsWith("/core.dart")) { | 20 if (uri.path.endsWith("/core.dart")) { |
20 source = """ | 21 source = """ |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 96 |
96 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 97 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
97 if (uri == null) { | 98 if (uri == null) { |
98 print('$kind: $message'); | 99 print('$kind: $message'); |
99 } else { | 100 } else { |
100 print('$uri:$begin:$end: $kind: $message'); | 101 print('$uri:$begin:$end: $kind: $message'); |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 main() { | 105 main() { |
| 106 asyncStart(); |
105 Future<String> result = | 107 Future<String> result = |
106 compile(new Uri(scheme: 'main'), | 108 compile(new Uri(scheme: 'main'), |
107 new Uri(scheme: 'lib', path: '/'), | 109 new Uri(scheme: 'lib', path: '/'), |
108 new Uri(scheme: 'package', path: '/'), | 110 new Uri(scheme: 'package', path: '/'), |
109 provider, handler); | 111 provider, handler); |
110 result.then((String code) { | 112 result.then((String code) { |
111 if (code == null) { | 113 if (code == null) { |
112 throw 'Compilation failed'; | 114 throw 'Compilation failed'; |
113 } | 115 } |
114 }, onError: (e) { | 116 }, onError: (e) { |
115 throw 'Compilation failed'; | 117 throw 'Compilation failed'; |
116 }); | 118 }).whenComplete(() => asyncEnd()); |
117 } | 119 } |
OLD | NEW |