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