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 {}'; | |
38 } else { | 36 } else { |
39 source = "#library('lib');"; | 37 source = "#library('lib');"; |
40 } | 38 } |
41 } else { | 39 } else { |
42 throw "unexpected URI $uri"; | 40 throw "unexpected URI $uri"; |
43 } | 41 } |
44 completer.complete(source); | 42 completer.complete(source); |
45 return completer.future; | 43 return completer.future; |
46 } | 44 } |
47 | 45 |
48 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 46 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
49 if (uri === null) { | 47 if (uri === null) { |
50 print('$kind: $message'); | 48 print('$kind: $message'); |
51 } else { | 49 } else { |
52 print('$uri:$begin:$end: $kind: $message'); | 50 print('$uri:$begin:$end: $kind: $message'); |
53 } | 51 } |
54 } | 52 } |
55 | 53 |
56 main() { | 54 main() { |
57 String code = compile(new Uri.fromComponents(scheme: 'main'), | 55 String code = compile(new Uri.fromComponents(scheme: 'main'), |
58 new Uri.fromComponents(scheme: 'lib'), | 56 new Uri.fromComponents(scheme: 'lib'), |
59 new Uri.fromComponents(scheme: 'package'), | 57 new Uri.fromComponents(scheme: 'package'), |
60 provider, handler).value; | 58 provider, handler).value; |
61 if (code === null) { | 59 if (code === null) { |
62 throw 'Compilation failed'; | 60 throw 'Compilation failed'; |
63 } | 61 } |
64 } | 62 } |
OLD | NEW |