| 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 library mock_compiler; | 5 library mock_compiler; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 | 10 |
| 11 import 'package:compiler/compiler.dart' as api; | 11 import 'package:compiler/compiler.dart' as api; |
| 12 import 'package:compiler/compiler_new.dart' as new_api; |
| 12 import 'package:compiler/src/common/names.dart' show | 13 import 'package:compiler/src/common/names.dart' show |
| 13 Uris; | 14 Uris; |
| 14 import 'package:compiler/src/constants/expressions.dart'; | 15 import 'package:compiler/src/constants/expressions.dart'; |
| 15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; | 16 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; |
| 16 import 'package:compiler/src/diagnostics/source_span.dart'; | 17 import 'package:compiler/src/diagnostics/source_span.dart'; |
| 17 import 'package:compiler/src/diagnostics/spannable.dart'; | 18 import 'package:compiler/src/diagnostics/spannable.dart'; |
| 18 import 'package:compiler/src/elements/elements.dart'; | 19 import 'package:compiler/src/elements/elements.dart'; |
| 19 import 'package:compiler/src/js_backend/backend_helpers.dart' | 20 import 'package:compiler/src/js_backend/backend_helpers.dart' |
| 20 show BackendHelpers; | 21 show BackendHelpers; |
| 21 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' | 22 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Node parsedTree; | 63 Node parsedTree; |
| 63 final String testedPatchVersion; | 64 final String testedPatchVersion; |
| 64 final LibrarySourceProvider librariesOverride; | 65 final LibrarySourceProvider librariesOverride; |
| 65 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); | 66 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); |
| 66 | 67 |
| 67 MockCompiler.internal( | 68 MockCompiler.internal( |
| 68 {Map<String, String> coreSource, | 69 {Map<String, String> coreSource, |
| 69 bool enableTypeAssertions: false, | 70 bool enableTypeAssertions: false, |
| 70 bool enableUserAssertions: false, | 71 bool enableUserAssertions: false, |
| 71 bool enableMinification: false, | 72 bool enableMinification: false, |
| 72 int maxConcreteTypeSize: 5, | |
| 73 bool disableTypeInference: false, | 73 bool disableTypeInference: false, |
| 74 bool analyzeAll: false, | 74 bool analyzeAll: false, |
| 75 bool analyzeOnly: false, | 75 bool analyzeOnly: false, |
| 76 bool emitJavaScript: true, | 76 bool emitJavaScript: true, |
| 77 bool preserveComments: false, | 77 bool preserveComments: false, |
| 78 // Our unit tests check code generation output that is | 78 // Our unit tests check code generation output that is |
| 79 // affected by inlining support. | 79 // affected by inlining support. |
| 80 bool disableInlining: true, | 80 bool disableInlining: true, |
| 81 bool trustTypeAnnotations: false, | 81 bool trustTypeAnnotations: false, |
| 82 bool trustJSInteropTypeAnnotations: false, | 82 bool trustJSInteropTypeAnnotations: false, |
| 83 bool enableAsyncAwait: false, | 83 bool enableAsyncAwait: false, |
| 84 int this.expectedWarnings, | 84 int this.expectedWarnings, |
| 85 int this.expectedErrors, | 85 int this.expectedErrors, |
| 86 api.CompilerOutputProvider outputProvider, | 86 api.CompilerOutputProvider outputProvider, |
| 87 String patchVersion, | 87 String patchVersion, |
| 88 LibrarySourceProvider this.librariesOverride}) | 88 LibrarySourceProvider this.librariesOverride}) |
| 89 : sourceFiles = new Map<String, SourceFile>(), | 89 : sourceFiles = new Map<String, SourceFile>(), |
| 90 testedPatchVersion = patchVersion, | 90 testedPatchVersion = patchVersion, |
| 91 super(enableTypeAssertions: enableTypeAssertions, | 91 super(options: new new_api.CompilerOptions( |
| 92 entryPoint: new Uri(scheme: 'mock'), |
| 93 libraryRoot: Uri.parse('placeholder_library_root_for_mock/'), |
| 94 enableTypeAssertions: enableTypeAssertions, |
| 92 enableUserAssertions: enableUserAssertions, | 95 enableUserAssertions: enableUserAssertions, |
| 96 disableInlining: disableInlining, |
| 93 enableAssertMessage: true, | 97 enableAssertMessage: true, |
| 94 enableMinification: enableMinification, | 98 enableMinification: enableMinification, |
| 95 maxConcreteTypeSize: maxConcreteTypeSize, | 99 disableTypeInference: disableTypeInference, |
| 96 disableTypeInferenceFlag: disableTypeInference, | 100 analyzeAll: analyzeAll, |
| 97 analyzeAllFlag: analyzeAll, | |
| 98 analyzeOnly: analyzeOnly, | 101 analyzeOnly: analyzeOnly, |
| 99 emitJavaScript: emitJavaScript, | 102 emitJavaScript: emitJavaScript, |
| 100 preserveComments: preserveComments, | 103 preserveComments: preserveComments, |
| 101 trustTypeAnnotations: trustTypeAnnotations, | 104 trustTypeAnnotations: trustTypeAnnotations, |
| 102 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, | 105 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, |
| 103 diagnosticOptions: | 106 diagnosticOptions: |
| 104 new DiagnosticOptions(shownPackageWarnings: const []), | 107 new DiagnosticOptions(shownPackageWarnings: const [])), |
| 105 outputProvider: new LegacyCompilerOutput(outputProvider)) { | 108 outputProvider: new LegacyCompilerOutput(outputProvider)) { |
| 106 this.disableInlining = disableInlining; | |
| 107 | 109 |
| 108 deferredLoadTask = new MockDeferredLoadTask(this); | 110 deferredLoadTask = new MockDeferredLoadTask(this); |
| 109 | 111 |
| 110 registerSource(Uris.dart_core, | 112 registerSource(Uris.dart_core, |
| 111 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); | 113 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); |
| 112 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); | 114 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); |
| 113 | 115 |
| 114 registerSource(BackendHelpers.DART_JS_HELPER, | 116 registerSource(BackendHelpers.DART_JS_HELPER, |
| 115 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); | 117 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); |
| 116 registerSource(BackendHelpers.DART_FOREIGN_HELPER, | 118 registerSource(BackendHelpers.DART_FOREIGN_HELPER, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 trustTypeAnnotations: trustTypeAnnotations, | 371 trustTypeAnnotations: trustTypeAnnotations, |
| 370 enableTypeAssertions: enableTypeAssertions, | 372 enableTypeAssertions: enableTypeAssertions, |
| 371 enableUserAssertions: enableUserAssertions, | 373 enableUserAssertions: enableUserAssertions, |
| 372 expectedErrors: expectedErrors, | 374 expectedErrors: expectedErrors, |
| 373 expectedWarnings: expectedWarnings, | 375 expectedWarnings: expectedWarnings, |
| 374 outputProvider: outputProvider); | 376 outputProvider: outputProvider); |
| 375 compiler.registerSource(uri, code); | 377 compiler.registerSource(uri, code); |
| 376 compiler.diagnosticHandler = createHandler(compiler, code); | 378 compiler.diagnosticHandler = createHandler(compiler, code); |
| 377 return compiler; | 379 return compiler; |
| 378 } | 380 } |
| OLD | NEW |