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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library mock_compiler; 5 library mock_compiler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:compiler/compiler.dart' as api; 10 import 'package:compiler/compiler.dart' as api;
11 import 'package:compiler/src/common/names.dart' show 11 import 'package:compiler/src/common/names.dart' show Uris;
12 Uris;
13 import 'package:compiler/src/constants/expressions.dart'; 12 import 'package:compiler/src/constants/expressions.dart';
14 import 'package:compiler/src/dart_types.dart' show DartType; 13 import 'package:compiler/src/dart_types.dart' show DartType;
15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 14 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
16 import 'package:compiler/src/diagnostics/source_span.dart'; 15 import 'package:compiler/src/diagnostics/source_span.dart';
17 import 'package:compiler/src/diagnostics/spannable.dart'; 16 import 'package:compiler/src/diagnostics/spannable.dart';
18 import 'package:compiler/src/elements/elements.dart'; 17 import 'package:compiler/src/elements/elements.dart';
19 import 'package:compiler/src/elements/visitor.dart'; 18 import 'package:compiler/src/elements/visitor.dart';
20 import 'package:compiler/src/js_backend/backend_helpers.dart' show 19 import 'package:compiler/src/js_backend/backend_helpers.dart'
21 BackendHelpers; 20 show BackendHelpers;
22 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' show 21 import 'package:compiler/src/js_backend/lookup_map_analysis.dart'
23 LookupMapAnalysis; 22 show LookupMapAnalysis;
24 import 'package:compiler/src/io/source_file.dart'; 23 import 'package:compiler/src/io/source_file.dart';
25 import 'package:compiler/src/options.dart' show 24 import 'package:compiler/src/options.dart' show CompilerOptions;
26 CompilerOptions;
27 import 'package:compiler/src/resolution/members.dart'; 25 import 'package:compiler/src/resolution/members.dart';
28 import 'package:compiler/src/resolution/registry.dart'; 26 import 'package:compiler/src/resolution/registry.dart';
29 import 'package:compiler/src/resolution/scope.dart'; 27 import 'package:compiler/src/resolution/scope.dart';
30 import 'package:compiler/src/resolution/tree_elements.dart'; 28 import 'package:compiler/src/resolution/tree_elements.dart';
31 import 'package:compiler/src/resolved_uri_translator.dart'; 29 import 'package:compiler/src/resolved_uri_translator.dart';
32 import 'package:compiler/src/script.dart'; 30 import 'package:compiler/src/script.dart';
33 import 'package:compiler/src/tree/tree.dart'; 31 import 'package:compiler/src/tree/tree.dart';
34 import 'package:compiler/src/old_to_new_api.dart'; 32 import 'package:compiler/src/old_to_new_api.dart';
35 import 'parser_helper.dart'; 33 import 'parser_helper.dart';
36 34
37 import 'package:compiler/src/elements/modelx.dart' show 35 import 'package:compiler/src/elements/modelx.dart'
38 ElementX, 36 show ElementX, LibraryElementX, ErroneousElementX, FunctionElementX;
39 LibraryElementX,
40 ErroneousElementX,
41 FunctionElementX;
42 37
43 import 'package:compiler/src/compiler.dart'; 38 import 'package:compiler/src/compiler.dart';
44 import 'package:compiler/src/common/tasks.dart' show Measurer; 39 import 'package:compiler/src/common/tasks.dart' show Measurer;
45 40
46 import 'package:compiler/src/deferred_load.dart' show 41 import 'package:compiler/src/deferred_load.dart'
47 DeferredLoadTask, 42 show DeferredLoadTask, OutputUnit;
48 OutputUnit;
49 43
50 import 'mock_libraries.dart'; 44 import 'mock_libraries.dart';
51 import 'diagnostic_helper.dart'; 45 import 'diagnostic_helper.dart';
52 46
53 export 'diagnostic_helper.dart'; 47 export 'diagnostic_helper.dart';
54 48
55 final Uri PATCH_CORE = new Uri(scheme: 'patch', path: 'core'); 49 final Uri PATCH_CORE = new Uri(scheme: 'patch', path: 'core');
56 50
57 typedef String LibrarySourceProvider(Uri uri); 51 typedef String LibrarySourceProvider(Uri uri);
58 52
59 class MockCompiler extends Compiler { 53 class MockCompiler extends Compiler {
60 api.DiagnosticHandler diagnosticHandler; 54 api.DiagnosticHandler diagnosticHandler;
55
61 /// Expected number of warnings. If `null`, the number of warnings is 56 /// Expected number of warnings. If `null`, the number of warnings is
62 /// not checked. 57 /// not checked.
63 final int expectedWarnings; 58 final int expectedWarnings;
59
64 /// Expected number of errors. If `null`, the number of errors is not checked. 60 /// Expected number of errors. If `null`, the number of errors is not checked.
65 final int expectedErrors; 61 final int expectedErrors;
66 final Map<String, SourceFile> sourceFiles; 62 final Map<String, SourceFile> sourceFiles;
67 Node parsedTree; 63 Node parsedTree;
68 final String testedPatchVersion; 64 final String testedPatchVersion;
69 final LibrarySourceProvider librariesOverride; 65 final LibrarySourceProvider librariesOverride;
70 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); 66 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector();
71 final ResolvedUriTranslator resolvedUriTranslator = 67 final ResolvedUriTranslator resolvedUriTranslator =
72 new MockResolvedUriTranslator(); 68 new MockResolvedUriTranslator();
73 final Measurer measurer = new Measurer(); 69 final Measurer measurer = new Measurer();
74 70
75 MockCompiler.internal( 71 MockCompiler.internal(
76 {Map<String, String> coreSource, 72 {Map<String, String> coreSource,
77 bool enableTypeAssertions: false, 73 bool enableTypeAssertions: false,
78 bool enableUserAssertions: false, 74 bool enableUserAssertions: false,
79 bool enableMinification: false, 75 bool enableMinification: false,
80 bool disableTypeInference: false, 76 bool disableTypeInference: false,
81 bool analyzeAll: false, 77 bool analyzeAll: false,
82 bool analyzeOnly: false, 78 bool analyzeOnly: false,
83 bool preserveComments: false, 79 bool preserveComments: false,
84 // Our unit tests check code generation output that is 80 // Our unit tests check code generation output that is
85 // affected by inlining support. 81 // affected by inlining support.
86 bool disableInlining: true, 82 bool disableInlining: true,
87 bool trustTypeAnnotations: false, 83 bool trustTypeAnnotations: false,
88 bool trustJSInteropTypeAnnotations: false, 84 bool trustJSInteropTypeAnnotations: false,
89 bool enableAsyncAwait: false, 85 bool enableAsyncAwait: false,
90 int this.expectedWarnings, 86 int this.expectedWarnings,
91 int this.expectedErrors, 87 int this.expectedErrors,
92 api.CompilerOutputProvider outputProvider, 88 api.CompilerOutputProvider outputProvider,
93 String patchVersion, 89 String patchVersion,
94 LibrarySourceProvider this.librariesOverride}) 90 LibrarySourceProvider this.librariesOverride})
95 : sourceFiles = new Map<String, SourceFile>(), 91 : sourceFiles = new Map<String, SourceFile>(),
96 testedPatchVersion = patchVersion, 92 testedPatchVersion = patchVersion,
97 super(options: new CompilerOptions( 93 super(
98 entryPoint: new Uri(scheme: 'mock'), 94 options: new CompilerOptions(
99 libraryRoot: Uri.parse('placeholder_library_root_for_mock/'), 95 entryPoint: new Uri(scheme: 'mock'),
100 enableTypeAssertions: enableTypeAssertions, 96 libraryRoot: Uri.parse('placeholder_library_root_for_mock/'),
101 enableUserAssertions: enableUserAssertions, 97 enableTypeAssertions: enableTypeAssertions,
102 disableInlining: disableInlining, 98 enableUserAssertions: enableUserAssertions,
103 enableAssertMessage: true, 99 disableInlining: disableInlining,
104 enableMinification: enableMinification, 100 enableAssertMessage: true,
105 disableTypeInference: disableTypeInference, 101 enableMinification: enableMinification,
106 analyzeAll: analyzeAll, 102 disableTypeInference: disableTypeInference,
107 analyzeOnly: analyzeOnly, 103 analyzeAll: analyzeAll,
108 preserveComments: preserveComments, 104 analyzeOnly: analyzeOnly,
109 trustTypeAnnotations: trustTypeAnnotations, 105 preserveComments: preserveComments,
110 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, 106 trustTypeAnnotations: trustTypeAnnotations,
111 shownPackageWarnings: const []), 107 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations,
112 outputProvider: new LegacyCompilerOutput(outputProvider)) { 108 shownPackageWarnings: const []),
113 109 outputProvider: new LegacyCompilerOutput(outputProvider)) {
114 deferredLoadTask = new MockDeferredLoadTask(this); 110 deferredLoadTask = new MockDeferredLoadTask(this);
115 111
116 registerSource(Uris.dart_core, 112 registerSource(
117 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); 113 Uris.dart_core, buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource));
118 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); 114 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE);
119 115
120 registerSource(BackendHelpers.DART_JS_HELPER, 116 registerSource(BackendHelpers.DART_JS_HELPER,
121 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); 117 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY));
122 registerSource(BackendHelpers.DART_FOREIGN_HELPER, 118 registerSource(BackendHelpers.DART_FOREIGN_HELPER,
123 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY)); 119 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY));
124 registerSource(BackendHelpers.DART_INTERCEPTORS, 120 registerSource(BackendHelpers.DART_INTERCEPTORS,
125 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY)); 121 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY));
126 registerSource(BackendHelpers.DART_ISOLATE_HELPER, 122 registerSource(BackendHelpers.DART_ISOLATE_HELPER,
127 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY)); 123 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY));
128 registerSource(Uris.dart_mirrors, DEFAULT_MIRRORS_SOURCE); 124 registerSource(Uris.dart_mirrors, DEFAULT_MIRRORS_SOURCE);
129 registerSource(BackendHelpers.DART_JS_MIRRORS, 125 registerSource(BackendHelpers.DART_JS_MIRRORS, DEFAULT_JS_MIRRORS_SOURCE);
130 DEFAULT_JS_MIRRORS_SOURCE);
131 126
132 Map<String, String> asyncLibrarySource = <String, String>{}; 127 Map<String, String> asyncLibrarySource = <String, String>{};
133 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY); 128 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY);
134 if (enableAsyncAwait) { 129 if (enableAsyncAwait) {
135 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY); 130 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY);
136 } 131 }
137 registerSource(Uris.dart_async, 132 registerSource(Uris.dart_async, buildLibrarySource(asyncLibrarySource));
138 buildLibrarySource(asyncLibrarySource));
139 registerSource(LookupMapAnalysis.PACKAGE_LOOKUP_MAP, 133 registerSource(LookupMapAnalysis.PACKAGE_LOOKUP_MAP,
140 buildLibrarySource(DEFAULT_LOOKUP_MAP_LIBRARY)); 134 buildLibrarySource(DEFAULT_LOOKUP_MAP_LIBRARY));
141 } 135 }
142 136
143 String get patchVersion { 137 String get patchVersion {
144 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; 138 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion;
145 } 139 }
146 140
147 /// Initialize the mock compiler with an empty main library. 141 /// Initialize the mock compiler with an empty main library.
148 Future<Uri> init([String mainSource = ""]) { 142 Future<Uri> init([String mainSource = ""]) {
149 Uri uri = new Uri(scheme: "mock"); 143 Uri uri = new Uri(scheme: "mock");
150 registerSource(uri, mainSource); 144 registerSource(uri, mainSource);
151 return libraryLoader.loadLibrary(uri) 145 return libraryLoader.loadLibrary(uri).then((LibraryElement library) {
152 .then((LibraryElement library) {
153 mainApp = library; 146 mainApp = library;
154 // We need to make sure the Object class is resolved. When registering a 147 // We need to make sure the Object class is resolved. When registering a
155 // dynamic invocation the ArgumentTypesRegistry eventually iterates over 148 // dynamic invocation the ArgumentTypesRegistry eventually iterates over
156 // the interfaces of the Object class which would be 'null' if the class 149 // the interfaces of the Object class which would be 'null' if the class
157 // wasn't resolved. 150 // wasn't resolved.
158 coreClasses.objectClass.ensureResolved(resolution); 151 coreClasses.objectClass.ensureResolved(resolution);
159 }).then((_) => uri); 152 }).then((_) => uri);
160 } 153 }
161 154
162 Future run(Uri uri, [String mainSource = ""]) { 155 Future run(Uri uri, [String mainSource = ""]) {
163 return init(mainSource).then((Uri mainUri) { 156 return init(mainSource).then((Uri mainUri) {
164 return super.run(uri == null ? mainUri : uri); 157 return super.run(uri == null ? mainUri : uri);
165 }).then((result) { 158 }).then((result) {
166 if (expectedErrors != null && 159 if (expectedErrors != null &&
167 expectedErrors != diagnosticCollector.errors.length) { 160 expectedErrors != diagnosticCollector.errors.length) {
168 throw "unexpected error during compilation " 161 throw "unexpected error during compilation "
169 "${diagnosticCollector.errors}"; 162 "${diagnosticCollector.errors}";
170 } else if (expectedWarnings != null && 163 } else if (expectedWarnings != null &&
171 expectedWarnings != diagnosticCollector.warnings.length) { 164 expectedWarnings != diagnosticCollector.warnings.length) {
172 throw "unexpected warnings during compilation " 165 throw "unexpected warnings during compilation "
173 "${diagnosticCollector.warnings}"; 166 "${diagnosticCollector.warnings}";
174 } else { 167 } else {
175 return result; 168 return result;
176 } 169 }
177 }); 170 });
178 } 171 }
179 172
180 /** 173 /**
181 * Registers the [source] with [uri] making it possible load [source] as a 174 * Registers the [source] with [uri] making it possible load [source] as a
182 * library. If an override has been provided in [librariesOverride], that 175 * library. If an override has been provided in [librariesOverride], that
183 * is used instead. 176 * is used instead.
184 */ 177 */
185 void registerSource(Uri uri, String source) { 178 void registerSource(Uri uri, String source) {
186 if (librariesOverride != null) { 179 if (librariesOverride != null) {
187 String override = librariesOverride(uri); 180 String override = librariesOverride(uri);
188 if (override != null) { 181 if (override != null) {
189 source = override; 182 source = override;
190 } 183 }
191 } 184 }
192 sourceFiles[uri.toString()] = new MockFile(source); 185 sourceFiles[uri.toString()] = new MockFile(source);
193 } 186 }
194 187
195 void reportDiagnostic(DiagnosticMessage message, 188 void reportDiagnostic(DiagnosticMessage message,
196 List<DiagnosticMessage> infoMessages, 189 List<DiagnosticMessage> infoMessages, api.Diagnostic kind) {
197 api.Diagnostic kind) {
198
199 void processMessage(DiagnosticMessage message, api.Diagnostic kind) { 190 void processMessage(DiagnosticMessage message, api.Diagnostic kind) {
200 SourceSpan span = message.sourceSpan; 191 SourceSpan span = message.sourceSpan;
201 Uri uri; 192 Uri uri;
202 int begin; 193 int begin;
203 int end; 194 int end;
204 String text = '${message.message}'; 195 String text = '${message.message}';
205 if (span != null) { 196 if (span != null) {
206 uri = span.uri; 197 uri = span.uri;
207 begin = span.begin; 198 begin = span.begin;
208 end = span.end; 199 end = span.end;
209 } 200 }
210 diagnosticCollector.report(message.message, uri, begin, end, text, kind); 201 diagnosticCollector.report(message.message, uri, begin, end, text, kind);
211 if (diagnosticHandler != null) { 202 if (diagnosticHandler != null) {
212 diagnosticHandler(uri, begin, end, text, kind); 203 diagnosticHandler(uri, begin, end, text, kind);
213 } 204 }
214 } 205 }
215 206
216 processMessage(message, kind); 207 processMessage(message, kind);
217 infoMessages.forEach((i) => processMessage(i, api.Diagnostic.INFO)); 208 infoMessages.forEach((i) => processMessage(i, api.Diagnostic.INFO));
218 } 209 }
219 210
220 CollectingTreeElements resolveStatement(String text) { 211 CollectingTreeElements resolveStatement(String text) {
221 parsedTree = parseStatement(text); 212 parsedTree = parseStatement(text);
222 return resolveNodeStatement(parsedTree, new MockElement(mainApp)); 213 return resolveNodeStatement(parsedTree, new MockElement(mainApp));
223 } 214 }
224 215
225 TreeElementMapping resolveNodeStatement(Node tree, 216 TreeElementMapping resolveNodeStatement(
226 ExecutableElement element) { 217 Node tree, ExecutableElement element) {
227 ResolverVisitor visitor = 218 ResolverVisitor visitor = new ResolverVisitor(
228 new ResolverVisitor( 219 this.resolution,
229 this.resolution, 220 element,
230 element, 221 new ResolutionRegistry(
231 new ResolutionRegistry(this.backend, 222 this.backend, new CollectingTreeElements(element)),
232 new CollectingTreeElements(element)), 223 scope:
233 scope: new MockTypeVariablesScope( 224 new MockTypeVariablesScope(element.enclosingElement.buildScope()));
234 element.enclosingElement.buildScope()));
235 if (visitor.scope is LibraryScope || 225 if (visitor.scope is LibraryScope ||
236 visitor.scope is MockTypeVariablesScope) { 226 visitor.scope is MockTypeVariablesScope) {
237 visitor.scope = new MethodScope(visitor.scope, element); 227 visitor.scope = new MethodScope(visitor.scope, element);
238 } 228 }
239 visitor.visit(tree); 229 visitor.visit(tree);
240 visitor.scope = new LibraryScope(element.library); 230 visitor.scope = new LibraryScope(element.library);
241 return visitor.registry.mapping; 231 return visitor.registry.mapping;
242 } 232 }
243 233
244 resolverVisitor() { 234 resolverVisitor() {
245 Element mockElement = new MockElement(mainApp.entryCompilationUnit); 235 Element mockElement = new MockElement(mainApp.entryCompilationUnit);
246 ResolverVisitor visitor = 236 ResolverVisitor visitor = new ResolverVisitor(
247 new ResolverVisitor( 237 this.resolution,
248 this.resolution, 238 mockElement,
249 mockElement, 239 new ResolutionRegistry(
250 new ResolutionRegistry( 240 this.backend, new CollectingTreeElements(mockElement)),
251 this.backend, new CollectingTreeElements(mockElement)), 241 scope: mockElement.enclosingElement.buildScope());
252 scope: mockElement.enclosingElement.buildScope());
253 visitor.scope = new MethodScope(visitor.scope, mockElement); 242 visitor.scope = new MethodScope(visitor.scope, mockElement);
254 return visitor; 243 return visitor;
255 } 244 }
256 245
257 parseScript(String text, [LibraryElement library]) { 246 parseScript(String text, [LibraryElement library]) {
258 if (library == null) library = mainApp; 247 if (library == null) library = mainApp;
259 parseUnit(text, this, library, registerSource); 248 parseUnit(text, this, library, registerSource);
260 } 249 }
261 250
262 Future scanBuiltinLibraries() { 251 Future scanBuiltinLibraries() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // The mock compiler does not split the program in output units. 329 // The mock compiler does not split the program in output units.
341 class MockDeferredLoadTask extends DeferredLoadTask { 330 class MockDeferredLoadTask extends DeferredLoadTask {
342 MockDeferredLoadTask(Compiler compiler) : super(compiler); 331 MockDeferredLoadTask(Compiler compiler) : super(compiler);
343 332
344 OutputUnit getElementOutputUnit(dynamic dependency) { 333 OutputUnit getElementOutputUnit(dynamic dependency) {
345 return mainOutputUnit; 334 return mainOutputUnit;
346 } 335 }
347 } 336 }
348 337
349 api.DiagnosticHandler createHandler(MockCompiler compiler, String text, 338 api.DiagnosticHandler createHandler(MockCompiler compiler, String text,
350 {bool verbose: false}) { 339 {bool verbose: false}) {
351 return (uri, int begin, int end, String message, kind) { 340 return (uri, int begin, int end, String message, kind) {
352 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return; 341 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return;
353 SourceFile sourceFile; 342 SourceFile sourceFile;
354 if (uri == null) { 343 if (uri == null) {
355 sourceFile = new StringSourceFile.fromName('analysis', text); 344 sourceFile = new StringSourceFile.fromName('analysis', text);
356 } else { 345 } else {
357 sourceFile = compiler.sourceFiles[uri.toString()]; 346 sourceFile = compiler.sourceFiles[uri.toString()];
358 } 347 }
359 if (sourceFile != null && begin != null && end != null) { 348 if (sourceFile != null && begin != null && end != null) {
360 print('${kind}: ${sourceFile.getLocationMessage(message, begin, end)}'); 349 print('${kind}: ${sourceFile.getLocationMessage(message, begin, end)}');
361 } else { 350 } else {
362 print('${kind}: $message'); 351 print('${kind}: $message');
363 } 352 }
364 }; 353 };
365 } 354 }
366 355
367 class MockElement extends FunctionElementX { 356 class MockElement extends FunctionElementX {
368 MockElement(Element enclosingElement) 357 MockElement(Element enclosingElement)
369 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, 358 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, enclosingElement);
370 enclosingElement);
371 359
372 get node => null; 360 get node => null;
373 361
374 parseNode(_) => null; 362 parseNode(_) => null;
375 363
376 bool get hasNode => false; 364 bool get hasNode => false;
377 365
378 accept(ElementVisitor visitor, arg) { 366 accept(ElementVisitor visitor, arg) {
379 return visitor.visitMethodElement(this, arg); 367 return visitor.visitMethodElement(this, arg);
380 } 368 }
381 } 369 }
382 370
383 // TODO(herhut): Disallow warnings and errors during compilation by default. 371 // TODO(herhut): Disallow warnings and errors during compilation by default.
384 MockCompiler compilerFor(String code, Uri uri, 372 MockCompiler compilerFor(String code, Uri uri,
385 {bool analyzeAll: false, 373 {bool analyzeAll: false,
386 bool analyzeOnly: false, 374 bool analyzeOnly: false,
387 Map<String, String> coreSource, 375 Map<String, String> coreSource,
388 bool disableInlining: true, 376 bool disableInlining: true,
389 bool minify: false, 377 bool minify: false,
390 bool trustTypeAnnotations: false, 378 bool trustTypeAnnotations: false,
391 bool enableTypeAssertions: false, 379 bool enableTypeAssertions: false,
392 bool enableUserAssertions: false, 380 bool enableUserAssertions: false,
393 int expectedErrors, 381 int expectedErrors,
394 int expectedWarnings, 382 int expectedWarnings,
395 api.CompilerOutputProvider outputProvider}) { 383 api.CompilerOutputProvider outputProvider}) {
396 MockCompiler compiler = new MockCompiler.internal( 384 MockCompiler compiler = new MockCompiler.internal(
397 analyzeAll: analyzeAll, 385 analyzeAll: analyzeAll,
398 analyzeOnly: analyzeOnly, 386 analyzeOnly: analyzeOnly,
399 coreSource: coreSource, 387 coreSource: coreSource,
400 disableInlining: disableInlining, 388 disableInlining: disableInlining,
401 enableMinification: minify, 389 enableMinification: minify,
402 trustTypeAnnotations: trustTypeAnnotations, 390 trustTypeAnnotations: trustTypeAnnotations,
403 enableTypeAssertions: enableTypeAssertions, 391 enableTypeAssertions: enableTypeAssertions,
404 enableUserAssertions: enableUserAssertions, 392 enableUserAssertions: enableUserAssertions,
405 expectedErrors: expectedErrors, 393 expectedErrors: expectedErrors,
406 expectedWarnings: expectedWarnings, 394 expectedWarnings: expectedWarnings,
407 outputProvider: outputProvider); 395 outputProvider: outputProvider);
408 compiler.registerSource(uri, code); 396 compiler.registerSource(uri, code);
409 compiler.diagnosticHandler = createHandler(compiler, code); 397 compiler.diagnosticHandler = createHandler(compiler, code);
410 return compiler; 398 return compiler;
411 } 399 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/mixin_typevariable_test.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698