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

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

Issue 2000323006: Make CompilerTask independent of compiler. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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;
(...skipping 23 matching lines...) Expand all
34 import 'package:compiler/src/old_to_new_api.dart'; 34 import 'package:compiler/src/old_to_new_api.dart';
35 import 'parser_helper.dart'; 35 import 'parser_helper.dart';
36 36
37 import 'package:compiler/src/elements/modelx.dart' show 37 import 'package:compiler/src/elements/modelx.dart' show
38 ElementX, 38 ElementX,
39 LibraryElementX, 39 LibraryElementX,
40 ErroneousElementX, 40 ErroneousElementX,
41 FunctionElementX; 41 FunctionElementX;
42 42
43 import 'package:compiler/src/compiler.dart'; 43 import 'package:compiler/src/compiler.dart';
44 import 'package:compiler/src/common/tasks.dart' show Measurer;
44 45
45 import 'package:compiler/src/deferred_load.dart' show 46 import 'package:compiler/src/deferred_load.dart' show
46 DeferredLoadTask, 47 DeferredLoadTask,
47 OutputUnit; 48 OutputUnit;
48 49
49 import 'mock_libraries.dart'; 50 import 'mock_libraries.dart';
50 import 'diagnostic_helper.dart'; 51 import 'diagnostic_helper.dart';
51 52
52 export 'diagnostic_helper.dart'; 53 export 'diagnostic_helper.dart';
53 54
54 final Uri PATCH_CORE = new Uri(scheme: 'patch', path: 'core'); 55 final Uri PATCH_CORE = new Uri(scheme: 'patch', path: 'core');
55 56
56 typedef String LibrarySourceProvider(Uri uri); 57 typedef String LibrarySourceProvider(Uri uri);
57 58
58 class MockCompiler extends Compiler { 59 class MockCompiler extends Compiler {
59 api.DiagnosticHandler diagnosticHandler; 60 api.DiagnosticHandler diagnosticHandler;
60 /// Expected number of warnings. If `null`, the number of warnings is 61 /// Expected number of warnings. If `null`, the number of warnings is
61 /// not checked. 62 /// not checked.
62 final int expectedWarnings; 63 final int expectedWarnings;
63 /// Expected number of errors. If `null`, the number of errors is not checked. 64 /// Expected number of errors. If `null`, the number of errors is not checked.
64 final int expectedErrors; 65 final int expectedErrors;
65 final Map<String, SourceFile> sourceFiles; 66 final Map<String, SourceFile> sourceFiles;
66 Node parsedTree; 67 Node parsedTree;
67 final String testedPatchVersion; 68 final String testedPatchVersion;
68 final LibrarySourceProvider librariesOverride; 69 final LibrarySourceProvider librariesOverride;
69 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); 70 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector();
70 final ResolvedUriTranslator resolvedUriTranslator = 71 final ResolvedUriTranslator resolvedUriTranslator =
71 new MockResolvedUriTranslator(); 72 new MockResolvedUriTranslator();
73 final Measurer measurer = new Measurer();
72 74
73 MockCompiler.internal( 75 MockCompiler.internal(
74 {Map<String, String> coreSource, 76 {Map<String, String> coreSource,
75 bool enableTypeAssertions: false, 77 bool enableTypeAssertions: false,
76 bool enableUserAssertions: false, 78 bool enableUserAssertions: false,
77 bool enableMinification: false, 79 bool enableMinification: false,
78 bool disableTypeInference: false, 80 bool disableTypeInference: false,
79 bool analyzeAll: false, 81 bool analyzeAll: false,
80 bool analyzeOnly: false, 82 bool analyzeOnly: false,
81 bool emitJavaScript: true, 83 bool emitJavaScript: true,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 trustTypeAnnotations: trustTypeAnnotations, 404 trustTypeAnnotations: trustTypeAnnotations,
403 enableTypeAssertions: enableTypeAssertions, 405 enableTypeAssertions: enableTypeAssertions,
404 enableUserAssertions: enableUserAssertions, 406 enableUserAssertions: enableUserAssertions,
405 expectedErrors: expectedErrors, 407 expectedErrors: expectedErrors,
406 expectedWarnings: expectedWarnings, 408 expectedWarnings: expectedWarnings,
407 outputProvider: outputProvider); 409 outputProvider: outputProvider);
408 compiler.registerSource(uri, code); 410 compiler.registerSource(uri, code);
409 compiler.diagnosticHandler = createHandler(compiler, code); 411 compiler.diagnosticHandler = createHandler(compiler, code);
410 return compiler; 412 return compiler;
411 } 413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698