| 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) { |
| 11 Completer<String> completer = new Completer<String>(); | 11 Completer<String> completer = new Completer<String>(); |
| 12 String source; | 12 String source; |
| 13 if (uri.scheme == "main") { | 13 if (uri.scheme == "main") { |
| 14 source = "main() {}"; | 14 source = "main() {}"; |
| 15 } else if (uri.scheme == "lib") { | 15 } else if (uri.scheme == "lib") { |
| 16 if (uri.path.endsWith("/core.dart")) { | 16 if (uri.path.endsWith("/core.dart")) { |
| 17 source = """#library('core'); | 17 source = """#library('core'); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 print(message); | 42 print(message); |
| 43 } | 43 } |
| 44 | 44 |
| 45 main() { | 45 main() { |
| 46 String code = compile(new Uri(scheme: 'main'), new Uri(scheme: 'lib'), | 46 String code = compile(new Uri(scheme: 'main'), new Uri(scheme: 'lib'), |
| 47 provider, handler).value; | 47 provider, handler).value; |
| 48 if (code === null) { | 48 if (code === null) { |
| 49 throw 'Compilation failed'; | 49 throw 'Compilation failed'; |
| 50 } | 50 } |
| 51 } | 51 } |
| OLD | NEW |