| 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) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class Map {} | 26 class Map {} |
| 27 class Closure {} | 27 class Closure {} |
| 28 class Dynamic_ {} | 28 class Dynamic_ {} |
| 29 class Null {} | 29 class Null {} |
| 30 getRuntimeTypeInfo(o) {} | 30 getRuntimeTypeInfo(o) {} |
| 31 setRuntimeTypeInfo(o, i) {} | 31 setRuntimeTypeInfo(o, i) {} |
| 32 eqNull(a) {} | 32 eqNull(a) {} |
| 33 eqNullB(a) {}"""; | 33 eqNullB(a) {}"""; |
| 34 } else if (uri.path.endsWith('_patch.dart')) { | 34 } else if (uri.path.endsWith('_patch.dart')) { |
| 35 source = ''; | 35 source = ''; |
| 36 } else if (uri.path.endsWith('js_helper.dart')) { |
| 37 source = 'library jshelper; class JSInvocationMirror {}'; |
| 36 } else { | 38 } else { |
| 37 source = "#library('lib');"; | 39 source = "#library('lib');"; |
| 38 } | 40 } |
| 39 } else { | 41 } else { |
| 40 throw "unexpected URI $uri"; | 42 throw "unexpected URI $uri"; |
| 41 } | 43 } |
| 42 completer.complete(source); | 44 completer.complete(source); |
| 43 return completer.future; | 45 return completer.future; |
| 44 } | 46 } |
| 45 | 47 |
| 46 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 48 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 47 if (uri === null) { | 49 if (uri === null) { |
| 48 print('$kind: $message'); | 50 print('$kind: $message'); |
| 49 } else { | 51 } else { |
| 50 print('$uri:$begin:$end: $kind: $message'); | 52 print('$uri:$begin:$end: $kind: $message'); |
| 51 } | 53 } |
| 52 } | 54 } |
| 53 | 55 |
| 54 main() { | 56 main() { |
| 55 String code = compile(new Uri.fromComponents(scheme: 'main'), | 57 String code = compile(new Uri.fromComponents(scheme: 'main'), |
| 56 new Uri.fromComponents(scheme: 'lib'), | 58 new Uri.fromComponents(scheme: 'lib'), |
| 57 new Uri.fromComponents(scheme: 'package'), | 59 new Uri.fromComponents(scheme: 'package'), |
| 58 provider, handler).value; | 60 provider, handler).value; |
| 59 if (code === null) { | 61 if (code === null) { |
| 60 throw 'Compilation failed'; | 62 throw 'Compilation failed'; |
| 61 } | 63 } |
| 62 } | 64 } |
| OLD | NEW |