| 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 "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 | 10 |
| 11 import 'package:compiler/compiler.dart'; | 11 import 'package:compiler/compiler.dart'; |
| 12 | 12 |
| 13 import '../compiler/dart2js/mock_libraries.dart'; | 13 import '../compiler/dart2js/mock_libraries.dart'; |
| 14 | 14 |
| 15 String libProvider(Uri uri) { | 15 String libProvider(Uri uri) { |
| 16 if (uri.path.endsWith(".platform")) { | 16 if (uri.path.endsWith(".platform")) { |
| 17 return DEFAULT_PLATFORM_CONFIG; | 17 return DEFAULT_PLATFORM_CONFIG; |
| 18 } | 18 } |
| 19 if (uri.path.endsWith("/core.dart")) { | 19 if (uri.path.endsWith("/core.dart")) { |
| 20 return buildLibrarySource(DEFAULT_CORE_LIBRARY); | 20 return buildLibrarySource(DEFAULT_CORE_LIBRARY); |
| 21 } else if (uri.path.endsWith('core_patch.dart')) { | 21 } else if (uri.path.endsWith('core_patch.dart')) { |
| 22 return DEFAULT_PATCH_CORE_SOURCE; | 22 return DEFAULT_PATCH_CORE_SOURCE; |
| 23 } else if (uri.path.endsWith('internal.dart')) { |
| 24 return buildLibrarySource(DEFAULT_INTERNAL_LIBRARY); |
| 23 } else if (uri.path.endsWith('interceptors.dart')) { | 25 } else if (uri.path.endsWith('interceptors.dart')) { |
| 24 return buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY); | 26 return buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY); |
| 25 } else if (uri.path.endsWith('js_helper.dart')) { | 27 } else if (uri.path.endsWith('js_helper.dart')) { |
| 26 return buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY); | 28 return buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY); |
| 27 } else if (uri.path.endsWith('isolate_helper.dart')) { | 29 } else if (uri.path.endsWith('isolate_helper.dart')) { |
| 28 return buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY); | 30 return buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY); |
| 29 } else if (uri.path.endsWith('/async.dart')) { | 31 } else if (uri.path.endsWith('/async.dart')) { |
| 30 return buildLibrarySource(DEFAULT_ASYNC_LIBRARY); | 32 return buildLibrarySource(DEFAULT_ASYNC_LIBRARY); |
| 31 } else { | 33 } else { |
| 32 return "library lib${uri.path.replaceAll('/', '.')};"; | 34 return "library lib${uri.path.replaceAll('/', '.')};"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 provider, | 64 provider, |
| 63 handler); | 65 handler); |
| 64 result.then((CompilationResult result) { | 66 result.then((CompilationResult result) { |
| 65 if (!result.isSuccess) { | 67 if (!result.isSuccess) { |
| 66 throw 'Compilation failed'; | 68 throw 'Compilation failed'; |
| 67 } | 69 } |
| 68 }, onError: (e, s) { | 70 }, onError: (e, s) { |
| 69 throw 'Compilation failed: $e\n$s'; | 71 throw 'Compilation failed: $e\n$s'; |
| 70 }).then(asyncSuccess); | 72 }).then(asyncSuccess); |
| 71 } | 73 } |
| OLD | NEW |