| 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 | 6 |
| 7 #import('../../lib/compiler/compiler.dart'); | 7 #import('../../lib/compiler/compiler.dart'); |
| 8 #import('dart:uri'); | 8 #import('dart:uri'); |
| 9 | 9 |
| 10 Future<String> provider(Uri uri) { | 10 Future<String> provider(Uri uri) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } else { | 33 } else { |
| 34 source = "#library('lib');"; | 34 source = "#library('lib');"; |
| 35 } | 35 } |
| 36 } else { | 36 } else { |
| 37 throw "unexpected URI $uri"; | 37 throw "unexpected URI $uri"; |
| 38 } | 38 } |
| 39 completer.complete(source); | 39 completer.complete(source); |
| 40 return completer.future; | 40 return completer.future; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void handler(Uri uri, int begin, int end, String message, bool fatal) { | 43 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 44 print(message); | 44 if (uri === null) { |
| 45 print('$kind: $message'); |
| 46 } else { |
| 47 print('$uri:$begin:$end: $kind: $message'); |
| 48 } |
| 45 } | 49 } |
| 46 | 50 |
| 47 main() { | 51 main() { |
| 48 String code = compile(new Uri(scheme: 'main'), | 52 String code = compile(new Uri(scheme: 'main'), |
| 49 new Uri(scheme: 'lib'), | 53 new Uri(scheme: 'lib'), |
| 50 new Uri(scheme: 'package'), | 54 new Uri(scheme: 'package'), |
| 51 provider, handler).value; | 55 provider, handler).value; |
| 52 if (code === null) { | 56 if (code === null) { |
| 53 throw 'Compilation failed'; | 57 throw 'Compilation failed'; |
| 54 } | 58 } |
| 55 } | 59 } |
| OLD | NEW |