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