| 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 // VMOptions= | 4 // VMOptions= |
| 5 // VMOptions=--print-object-histogram | 5 // VMOptions=--print-object-histogram |
| 6 | 6 |
| 7 // Smoke test of the dart2js compiler API. | 7 // Smoke test of the dart2js compiler API. |
| 8 library dummy_compiler; | 8 library dummy_compiler; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import "package:async_helper/async_helper.dart"; | 11 import "package:async_helper/async_helper.dart"; |
| 12 | 12 |
| 13 import 'package:compiler/compiler.dart'; | 13 import 'package:compiler/compiler.dart'; |
| 14 | 14 |
| 15 import '../compiler/dart2js/mock_libraries.dart'; | 15 import '../compiler/dart2js/mock_libraries.dart'; |
| 16 | 16 |
| 17 String libProvider(Uri uri) { | 17 String libProvider(Uri uri) { |
| 18 if (uri.path.endsWith("/core.dart")) { | 18 if (uri.path.endsWith("/core.dart")) { |
| 19 return buildLibrarySource(DEFAULT_CORE_LIBRARY); | 19 return buildLibrarySource(DEFAULT_CORE_LIBRARY); |
| 20 } else if (uri.path.endsWith('core_patch.dart')) { | 20 } else if (uri.path.endsWith('core_patch.dart')) { |
| 21 return DEFAULT_PATCH_CORE_SOURCE; | 21 return DEFAULT_PATCH_CORE_SOURCE; |
| 22 } else if (uri.path.endsWith('interceptors.dart')) { | 22 } else if (uri.path.endsWith('interceptors.dart')) { |
| 23 return buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY); | 23 return buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY); |
| 24 } else if (uri.path.endsWith('js_helper.dart')) { | 24 } else if (uri.path.endsWith('js_helper.dart')) { |
| 25 return buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY); | 25 return buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY); |
| 26 } else if (uri.path.endsWith('isolate_helper.dart')) { | 26 } else if (uri.path.endsWith('isolate_helper.dart')) { |
| 27 return buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY); | 27 return buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY); |
| 28 } else if (uri.path.endsWith('/async.dart')) { |
| 29 return buildLibrarySource(DEFAULT_ASYNC_LIBRARY); |
| 28 } else { | 30 } else { |
| 29 return "library lib${uri.path.replaceAll('/', '.')};"; | 31 return "library lib${uri.path.replaceAll('/', '.')};"; |
| 30 } | 32 } |
| 31 } | 33 } |
| 32 | 34 |
| 33 Future<String> provider(Uri uri) { | 35 Future<String> provider(Uri uri) { |
| 34 String source; | 36 String source; |
| 35 if (uri.scheme == "main") { | 37 if (uri.scheme == "main") { |
| 36 source = "main() {}"; | 38 source = "main() {}"; |
| 37 } else if (uri.scheme == "lib") { | 39 } else if (uri.scheme == "lib") { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 58 new Uri(scheme: 'package', path: '/'), | 60 new Uri(scheme: 'package', path: '/'), |
| 59 provider, handler); | 61 provider, handler); |
| 60 result.then((CompilationResult result) { | 62 result.then((CompilationResult result) { |
| 61 if (!result.isSuccess) { | 63 if (!result.isSuccess) { |
| 62 throw 'Compilation failed'; | 64 throw 'Compilation failed'; |
| 63 } | 65 } |
| 64 }, onError: (e, s) { | 66 }, onError: (e, s) { |
| 65 throw 'Compilation failed: $e\n$s'; | 67 throw 'Compilation failed: $e\n$s'; |
| 66 }).then(asyncSuccess); | 68 }).then(asyncSuccess); |
| 67 } | 69 } |
| OLD | NEW |