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

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

Issue 824103005: Revert "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
20 runCompiler(String main, List<String> options, 18 runCompiler(String main, List<String> options,
21 onValue(String code, List errors, List warnings)) { 19 onValue(String code, List errors, List warnings)) {
22 List errors = new List(); 20 List errors = new List();
23 List warnings = new List(); 21 List warnings = new List();
24 22
25 Future<String> localProvider(Uri uri) { 23 Future<String> localProvider(Uri uri) {
26 if (uri.scheme != 'main') return dummy.provider(uri); 24 if (uri.scheme != 'main') return dummy.provider(uri);
27 return new Future<String>.value(main); 25 return new Future<String>.value(main);
28 } 26 }
29 27
30 void localHandler(Uri uri, int begin, int end, 28 void localHandler(Uri uri, int begin, int end,
31 String message, Diagnostic kind) { 29 String message, Diagnostic kind) {
32 dummy.handler(uri, begin, end, message, kind); 30 dummy.handler(uri, begin, end, message, kind);
33 if (kind == Diagnostic.ERROR) { 31 if (kind == Diagnostic.ERROR) {
34 errors.add(message); 32 errors.add(message);
35 } else if (kind == Diagnostic.WARNING) { 33 } else if (kind == Diagnostic.WARNING) {
36 warnings.add(message); 34 warnings.add(message);
37 } 35 }
38 } 36 }
39 37
40 print('-----------------------------------------------'); 38 print('-----------------------------------------------');
41 print('main source:\n$main'); 39 print('main source:\n$main');
42 print('options: $options\n'); 40 print('options: $options\n');
43 asyncStart(); 41 asyncStart();
44 OutputCollector outputCollector = new OutputCollector(); 42 Future<String> result =
45 Future<CompilationResult> result =
46 compile(new Uri(scheme: 'main'), 43 compile(new Uri(scheme: 'main'),
47 new Uri(scheme: 'lib', path: '/'), 44 new Uri(scheme: 'lib', path: '/'),
48 new Uri(scheme: 'package', path: '/'), 45 new Uri(scheme: 'package', path: '/'),
49 localProvider, localHandler, options, outputCollector); 46 localProvider, localHandler, options);
50 result.then((_) { 47 result.then((String code) {
51 onValue(outputCollector.getOutput('', 'js'), errors, warnings); 48 onValue(code, errors, warnings);
52 }, onError: (e) { 49 }, onError: (e) {
53 throw 'Compilation failed: ${Error.safeToString(e)}'; 50 throw 'Compilation failed: ${Error.safeToString(e)}';
54 }).then(asyncSuccess).catchError((error, stack) { 51 }).then(asyncSuccess).catchError((error, stack) {
55 print('\n\n-----------------------------------------------'); 52 print('\n\n-----------------------------------------------');
56 print('main source:\n$main'); 53 print('main source:\n$main');
57 print('options: $options\n'); 54 print('options: $options\n');
58 print('threw:\n $error\n$stack'); 55 print('threw:\n $error\n$stack');
59 print('-----------------------------------------------\n\n'); 56 print('-----------------------------------------------\n\n');
60 throw error; 57 throw error;
61 }); 58 });
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // --analyze-signatures-only implies --analyze-only 168 // --analyze-signatures-only implies --analyze-only
172 runCompiler( 169 runCompiler(
173 "", 170 "",
174 ['--analyze-signatures-only', '--analyze-all'], 171 ['--analyze-signatures-only', '--analyze-all'],
175 (String code, List errors, List warnings) { 172 (String code, List errors, List warnings) {
176 Expect.isNull(code); 173 Expect.isNull(code);
177 Expect.isTrue(errors.isEmpty); 174 Expect.isTrue(errors.isEmpty);
178 Expect.isTrue(warnings.isEmpty); 175 Expect.isTrue(warnings.isEmpty);
179 }); 176 });
180 } 177 }
OLDNEW
« no previous file with comments | « pkg/dart2js_incremental/lib/caching_compiler.dart ('k') | tests/compiler/dart2js/backend_dart/dart_backend_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698