| 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'; | |
| 10 | 9 |
| 11 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 10 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
| 12 | 11 |
| 13 Future<String> provider(Uri uri) { | 12 Future<String> provider(Uri uri) { |
| 14 String source; | 13 String source; |
| 15 if (uri.scheme == "main") { | 14 if (uri.scheme == "main") { |
| 16 source = "main() {}"; | 15 source = "main() {}"; |
| 17 } else if (uri.scheme == "lib") { | 16 } else if (uri.scheme == "lib") { |
| 18 if (uri.path.endsWith("/core.dart")) { | 17 if (uri.path.endsWith("/core.dart")) { |
| 19 source = """library core; | 18 source = """library core; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 86 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 88 if (uri == null) { | 87 if (uri == null) { |
| 89 print('$kind: $message'); | 88 print('$kind: $message'); |
| 90 } else { | 89 } else { |
| 91 print('$uri:$begin:$end: $kind: $message'); | 90 print('$uri:$begin:$end: $kind: $message'); |
| 92 } | 91 } |
| 93 } | 92 } |
| 94 | 93 |
| 95 main() { | 94 main() { |
| 96 Future<String> result = | 95 Future<String> result = |
| 97 compile(new Uri.fromComponents(scheme: 'main'), | 96 compile(new Uri(scheme: 'main'), |
| 98 new Uri.fromComponents(scheme: 'lib', path: '/'), | 97 new Uri(scheme: 'lib', path: '/'), |
| 99 new Uri.fromComponents(scheme: 'package', path: '/'), | 98 new Uri(scheme: 'package', path: '/'), |
| 100 provider, handler); | 99 provider, handler); |
| 101 result.then((String code) { | 100 result.then((String code) { |
| 102 if (code == null) { | 101 if (code == null) { |
| 103 throw 'Compilation failed'; | 102 throw 'Compilation failed'; |
| 104 } | 103 } |
| 105 }, onError: (e) { | 104 }, onError: (e) { |
| 106 throw 'Compilation failed'; | 105 throw 'Compilation failed'; |
| 107 }); | 106 }); |
| 108 } | 107 } |
| OLD | NEW |