| 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 '../../sdk/lib/_internal/compiler/compiler.dart'; | 7 import '../../sdk/lib/_internal/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 29 matching lines...) Expand all Loading... |
| 40 source = "#library('lib');"; | 40 source = "#library('lib');"; |
| 41 } | 41 } |
| 42 } else { | 42 } else { |
| 43 throw "unexpected URI $uri"; | 43 throw "unexpected URI $uri"; |
| 44 } | 44 } |
| 45 completer.complete(source); | 45 completer.complete(source); |
| 46 return completer.future; | 46 return completer.future; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 49 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 50 if (uri === null) { | 50 if (uri == null) { |
| 51 print('$kind: $message'); | 51 print('$kind: $message'); |
| 52 } else { | 52 } else { |
| 53 print('$uri:$begin:$end: $kind: $message'); | 53 print('$uri:$begin:$end: $kind: $message'); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 main() { | 57 main() { |
| 58 String code = compile(new Uri.fromComponents(scheme: 'main'), | 58 String code = compile(new Uri.fromComponents(scheme: 'main'), |
| 59 new Uri.fromComponents(scheme: 'lib', path: '/'), | 59 new Uri.fromComponents(scheme: 'lib', path: '/'), |
| 60 new Uri.fromComponents(scheme: 'package', path: '/'), | 60 new Uri.fromComponents(scheme: 'package', path: '/'), |
| 61 provider, handler).value; | 61 provider, handler).value; |
| 62 if (code === null) { | 62 if (code == null) { |
| 63 throw 'Compilation failed'; | 63 throw 'Compilation failed'; |
| 64 } | 64 } |
| 65 } | 65 } |
| OLD | NEW |