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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 /// Expected number of errors. If `null`, the number of errors is not checked. | 67 /// Expected number of errors. If `null`, the number of errors is not checked. |
68 final int expectedErrors; | 68 final int expectedErrors; |
69 final Map<String, SourceFile> sourceFiles; | 69 final Map<String, SourceFile> sourceFiles; |
70 Node parsedTree; | 70 Node parsedTree; |
71 final String testedPatchVersion; | 71 final String testedPatchVersion; |
72 final LibrarySourceProvider librariesOverride; | 72 final LibrarySourceProvider librariesOverride; |
73 | 73 |
74 MockCompiler.internal( | 74 MockCompiler.internal( |
75 {Map<String, String> coreSource, | 75 {Map<String, String> coreSource, |
76 bool enableTypeAssertions: false, | 76 bool enableTypeAssertions: false, |
77 bool enableUserAssertions: false, | |
78 bool enableMinification: false, | 77 bool enableMinification: false, |
79 bool enableConcreteTypeInference: false, | 78 bool enableConcreteTypeInference: false, |
80 int maxConcreteTypeSize: 5, | 79 int maxConcreteTypeSize: 5, |
81 bool disableTypeInference: false, | 80 bool disableTypeInference: false, |
82 bool analyzeAll: false, | 81 bool analyzeAll: false, |
83 bool analyzeOnly: false, | 82 bool analyzeOnly: false, |
84 bool emitJavaScript: true, | 83 bool emitJavaScript: true, |
85 bool preserveComments: false, | 84 bool preserveComments: false, |
86 // Our unit tests check code generation output that is | 85 // Our unit tests check code generation output that is |
87 // affected by inlining support. | 86 // affected by inlining support. |
88 bool disableInlining: true, | 87 bool disableInlining: true, |
89 bool trustTypeAnnotations: false, | 88 bool trustTypeAnnotations: false, |
90 bool enableAsyncAwait: false, | 89 bool enableAsyncAwait: false, |
91 int this.expectedWarnings, | 90 int this.expectedWarnings, |
92 int this.expectedErrors, | 91 int this.expectedErrors, |
93 api.CompilerOutputProvider outputProvider, | 92 api.CompilerOutputProvider outputProvider, |
94 String patchVersion, | 93 String patchVersion, |
95 LibrarySourceProvider this.librariesOverride}) | 94 LibrarySourceProvider this.librariesOverride}) |
96 : sourceFiles = new Map<String, SourceFile>(), | 95 : sourceFiles = new Map<String, SourceFile>(), |
97 testedPatchVersion = patchVersion, | 96 testedPatchVersion = patchVersion, |
98 super(enableTypeAssertions: enableTypeAssertions, | 97 super(enableTypeAssertions: enableTypeAssertions, |
99 enableUserAssertions: enableUserAssertions, | |
100 enableMinification: enableMinification, | 98 enableMinification: enableMinification, |
101 enableConcreteTypeInference: enableConcreteTypeInference, | 99 enableConcreteTypeInference: enableConcreteTypeInference, |
102 maxConcreteTypeSize: maxConcreteTypeSize, | 100 maxConcreteTypeSize: maxConcreteTypeSize, |
103 disableTypeInferenceFlag: disableTypeInference, | 101 disableTypeInferenceFlag: disableTypeInference, |
104 analyzeAllFlag: analyzeAll, | 102 analyzeAllFlag: analyzeAll, |
105 analyzeOnly: analyzeOnly, | 103 analyzeOnly: analyzeOnly, |
106 emitJavaScript: emitJavaScript, | 104 emitJavaScript: emitJavaScript, |
107 preserveComments: preserveComments, | 105 preserveComments: preserveComments, |
108 trustTypeAnnotations: trustTypeAnnotations, | 106 trustTypeAnnotations: trustTypeAnnotations, |
109 showPackageWarnings: true, | 107 showPackageWarnings: true, |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 440 |
443 // TODO(herhut): Disallow warnings and errors during compilation by default. | 441 // TODO(herhut): Disallow warnings and errors during compilation by default. |
444 MockCompiler compilerFor(String code, Uri uri, | 442 MockCompiler compilerFor(String code, Uri uri, |
445 {bool analyzeAll: false, | 443 {bool analyzeAll: false, |
446 bool analyzeOnly: false, | 444 bool analyzeOnly: false, |
447 Map<String, String> coreSource, | 445 Map<String, String> coreSource, |
448 bool disableInlining: true, | 446 bool disableInlining: true, |
449 bool minify: false, | 447 bool minify: false, |
450 bool trustTypeAnnotations: false, | 448 bool trustTypeAnnotations: false, |
451 bool enableTypeAssertions: false, | 449 bool enableTypeAssertions: false, |
452 bool enableUserAssertions: false, | |
453 int expectedErrors, | 450 int expectedErrors, |
454 int expectedWarnings, | 451 int expectedWarnings, |
455 api.CompilerOutputProvider outputProvider}) { | 452 api.CompilerOutputProvider outputProvider}) { |
456 MockCompiler compiler = new MockCompiler.internal( | 453 MockCompiler compiler = new MockCompiler.internal( |
457 analyzeAll: analyzeAll, | 454 analyzeAll: analyzeAll, |
458 analyzeOnly: analyzeOnly, | 455 analyzeOnly: analyzeOnly, |
459 coreSource: coreSource, | 456 coreSource: coreSource, |
460 disableInlining: disableInlining, | 457 disableInlining: disableInlining, |
461 enableMinification: minify, | 458 enableMinification: minify, |
462 trustTypeAnnotations: trustTypeAnnotations, | 459 trustTypeAnnotations: trustTypeAnnotations, |
463 enableTypeAssertions: enableTypeAssertions, | 460 enableTypeAssertions: enableTypeAssertions, |
464 enableUserAssertions: enableUserAssertions, | |
465 expectedErrors: expectedErrors, | 461 expectedErrors: expectedErrors, |
466 expectedWarnings: expectedWarnings, | 462 expectedWarnings: expectedWarnings, |
467 outputProvider: outputProvider); | 463 outputProvider: outputProvider); |
468 compiler.registerSource(uri, code); | 464 compiler.registerSource(uri, code); |
469 compiler.diagnosticHandler = createHandler(compiler, code); | 465 compiler.diagnosticHandler = createHandler(compiler, code); |
470 return compiler; | 466 return compiler; |
471 } | 467 } |
OLD | NEW |