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 'dart:uri'; | |
10 | 9 |
11 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 10 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
12 | 11 |
13 Future<String> provider(Uri uri) { | 12 Future<String> provider(Uri uri) { |
14 String source; | 13 String source; |
15 if (uri.scheme == "main") { | 14 if (uri.scheme == "main") { |
16 source = "main() {}"; | 15 source = "main() {}"; |
17 } else if (uri.scheme == "lib") { | 16 } else if (uri.scheme == "lib") { |
18 if (uri.path.endsWith("/core.dart")) { | 17 if (uri.path.endsWith("/core.dart")) { |
19 source = """library core; | 18 source = """library core; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 85 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
87 if (uri == null) { | 86 if (uri == null) { |
88 print('$kind: $message'); | 87 print('$kind: $message'); |
89 } else { | 88 } else { |
90 print('$uri:$begin:$end: $kind: $message'); | 89 print('$uri:$begin:$end: $kind: $message'); |
91 } | 90 } |
92 } | 91 } |
93 | 92 |
94 main() { | 93 main() { |
95 Future<String> result = | 94 Future<String> result = |
96 compile(new Uri.fromComponents(scheme: 'main'), | 95 compile(new Uri(scheme: 'main'), |
97 new Uri.fromComponents(scheme: 'lib', path: '/'), | 96 new Uri(scheme: 'lib', path: '/'), |
98 new Uri.fromComponents(scheme: 'package', path: '/'), | 97 new Uri(scheme: 'package', path: '/'), |
99 provider, handler); | 98 provider, handler); |
100 result.then((String code) { | 99 result.then((String code) { |
101 if (code == null) { | 100 if (code == null) { |
102 throw 'Compilation failed'; | 101 throw 'Compilation failed'; |
103 } | 102 } |
104 }, onError: (e) { | 103 }, onError: (e) { |
105 throw 'Compilation failed'; | 104 throw 'Compilation failed'; |
106 }); | 105 }); |
107 } | 106 } |
OLD | NEW |