Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: tests/compiler/dart2js/analyze_only_test.dart

Issue 832363002: Remove Compiler.assembledCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 analyze_only; 6 library analyze_only;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
11 11
12 import '../../utils/dummy_compiler_test.dart' as dummy; 12 import '../../utils/dummy_compiler_test.dart' as dummy;
13 import 'package:compiler/compiler.dart'; 13 import 'package:compiler/compiler.dart';
14 14
15 import 'package:compiler/src/dart2jslib.dart' show 15 import 'package:compiler/src/dart2jslib.dart' show
16 MessageKind; 16 MessageKind;
17 17
18 import 'output_collector.dart';
19
18 runCompiler(String main, List<String> options, 20 runCompiler(String main, List<String> options,
19 onValue(String code, List errors, List warnings)) { 21 onValue(String code, List errors, List warnings)) {
20 List errors = new List(); 22 List errors = new List();
21 List warnings = new List(); 23 List warnings = new List();
22 24
23 Future<String> localProvider(Uri uri) { 25 Future<String> localProvider(Uri uri) {
24 if (uri.scheme != 'main') return dummy.provider(uri); 26 if (uri.scheme != 'main') return dummy.provider(uri);
25 return new Future<String>.value(main); 27 return new Future<String>.value(main);
26 } 28 }
27 29
28 void localHandler(Uri uri, int begin, int end, 30 void localHandler(Uri uri, int begin, int end,
29 String message, Diagnostic kind) { 31 String message, Diagnostic kind) {
30 dummy.handler(uri, begin, end, message, kind); 32 dummy.handler(uri, begin, end, message, kind);
31 if (kind == Diagnostic.ERROR) { 33 if (kind == Diagnostic.ERROR) {
32 errors.add(message); 34 errors.add(message);
33 } else if (kind == Diagnostic.WARNING) { 35 } else if (kind == Diagnostic.WARNING) {
34 warnings.add(message); 36 warnings.add(message);
35 } 37 }
36 } 38 }
37 39
38 print('-----------------------------------------------'); 40 print('-----------------------------------------------');
39 print('main source:\n$main'); 41 print('main source:\n$main');
40 print('options: $options\n'); 42 print('options: $options\n');
41 asyncStart(); 43 asyncStart();
42 Future<String> result = 44 OutputCollector outputCollector = new OutputCollector();
45 Future<CompilationResult> result =
43 compile(new Uri(scheme: 'main'), 46 compile(new Uri(scheme: 'main'),
44 new Uri(scheme: 'lib', path: '/'), 47 new Uri(scheme: 'lib', path: '/'),
45 new Uri(scheme: 'package', path: '/'), 48 new Uri(scheme: 'package', path: '/'),
46 localProvider, localHandler, options); 49 localProvider, localHandler, options, outputCollector);
47 result.then((String code) { 50 result.then((_) {
48 onValue(code, errors, warnings); 51 onValue(outputCollector.getOutput('', 'js'), errors, warnings);
49 }, onError: (e) { 52 }, onError: (e) {
50 throw 'Compilation failed: ${Error.safeToString(e)}'; 53 throw 'Compilation failed: ${Error.safeToString(e)}';
51 }).then(asyncSuccess).catchError((error, stack) { 54 }).then(asyncSuccess).catchError((error, stack) {
52 print('\n\n-----------------------------------------------'); 55 print('\n\n-----------------------------------------------');
53 print('main source:\n$main'); 56 print('main source:\n$main');
54 print('options: $options\n'); 57 print('options: $options\n');
55 print('threw:\n $error\n$stack'); 58 print('threw:\n $error\n$stack');
56 print('-----------------------------------------------\n\n'); 59 print('-----------------------------------------------\n\n');
57 throw error; 60 throw error;
58 }); 61 });
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // --analyze-signatures-only implies --analyze-only 171 // --analyze-signatures-only implies --analyze-only
169 runCompiler( 172 runCompiler(
170 "", 173 "",
171 ['--analyze-signatures-only', '--analyze-all'], 174 ['--analyze-signatures-only', '--analyze-all'],
172 (String code, List errors, List warnings) { 175 (String code, List errors, List warnings) {
173 Expect.isNull(code); 176 Expect.isNull(code);
174 Expect.isTrue(errors.isEmpty); 177 Expect.isTrue(errors.isEmpty);
175 Expect.isTrue(warnings.isEmpty); 178 Expect.isTrue(warnings.isEmpty);
176 }); 179 });
177 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698