| 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 |
| 11 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 11 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
| 12 | 12 |
| 13 Future<String> provider(Uri uri) { | 13 Future<String> provider(Uri uri) { |
| 14 Completer<String> completer = new Completer<String>(); | 14 Completer<String> completer = new Completer<String>(); |
| 15 String source; | 15 String source; |
| 16 if (uri.scheme == "main") { | 16 if (uri.scheme == "main") { |
| 17 source = "main() {}"; | 17 source = "main() {}"; |
| 18 } else if (uri.scheme == "lib") { | 18 } else if (uri.scheme == "lib") { |
| 19 if (uri.path.endsWith("/core.dart")) { | 19 if (uri.path.endsWith("/core.dart")) { |
| 20 source = """library core; | 20 source = """library core; |
| 21 class Object {} | 21 class Object { |
| 22 operator==(other) {} |
| 23 } |
| 22 class Type {} | 24 class Type {} |
| 23 class bool {} | 25 class bool {} |
| 24 class num {} | 26 class num {} |
| 25 class int {} | 27 class int {} |
| 26 class double{} | 28 class double{} |
| 27 class String{} | 29 class String{} |
| 28 class Function{} | 30 class Function{} |
| 29 class List {} | 31 class List {} |
| 30 class Map {} | 32 class Map {} |
| 31 class Closure {} | 33 class Closure {} |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 new Uri.fromComponents(scheme: 'package', path: '/'), | 92 new Uri.fromComponents(scheme: 'package', path: '/'), |
| 91 provider, handler); | 93 provider, handler); |
| 92 result.then((String code) { | 94 result.then((String code) { |
| 93 if (code == null) { | 95 if (code == null) { |
| 94 throw 'Compilation failed'; | 96 throw 'Compilation failed'; |
| 95 } | 97 } |
| 96 }, onError: (AsyncError e) { | 98 }, onError: (AsyncError e) { |
| 97 throw 'Compilation failed'; | 99 throw 'Compilation failed'; |
| 98 }); | 100 }); |
| 99 } | 101 } |
| OLD | NEW |