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 | 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 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 73 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
74 if (uri == null) { | 74 if (uri == null) { |
75 print('$kind: $message'); | 75 print('$kind: $message'); |
76 } else { | 76 } else { |
77 print('$uri:$begin:$end: $kind: $message'); | 77 print('$uri:$begin:$end: $kind: $message'); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 main() { | 81 main() { |
82 String code = compile(new Uri.fromComponents(scheme: 'main'), | 82 Future<String> result = |
83 new Uri.fromComponents(scheme: 'lib', path: '/'), | 83 compile(new Uri.fromComponents(scheme: 'main'), |
84 new Uri.fromComponents(scheme: 'package', path: '/'), | 84 new Uri.fromComponents(scheme: 'lib', path: '/'), |
85 provider, handler).value; | 85 new Uri.fromComponents(scheme: 'package', path: '/'), |
86 if (code == null) { | 86 provider, handler); |
87 throw 'Compilation failed'; | 87 result.then((String code) { |
88 } | 88 if (code == null) { |
| 89 throw 'Compilation failed'; |
| 90 } |
| 91 }, onError: (AsyncError e) { |
| 92 throw 'Compilation failed'; |
| 93 }); |
89 } | 94 } |
OLD | NEW |