| 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 compiler_helper; | 5 library compiler_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 import 'package:compiler/compiler.dart' as api; | 10 import 'package:compiler/compiler.dart' as api; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 // TODO(herhut): Disallow warnings and errors during compilation by default. | 91 // TODO(herhut): Disallow warnings and errors during compilation by default. |
| 92 MockCompiler compilerFor(String code, Uri uri, | 92 MockCompiler compilerFor(String code, Uri uri, |
| 93 {bool analyzeAll: false, | 93 {bool analyzeAll: false, |
| 94 bool analyzeOnly: false, | 94 bool analyzeOnly: false, |
| 95 Map<String, String> coreSource, | 95 Map<String, String> coreSource, |
| 96 bool disableInlining: true, | 96 bool disableInlining: true, |
| 97 bool minify: false, | 97 bool minify: false, |
| 98 bool trustTypeAnnotations: false, | 98 bool trustTypeAnnotations: false, |
| 99 bool enableTypeAssertions: false, |
| 99 int expectedErrors, | 100 int expectedErrors, |
| 100 int expectedWarnings, | 101 int expectedWarnings, |
| 101 api.CompilerOutputProvider outputProvider}) { | 102 api.CompilerOutputProvider outputProvider}) { |
| 102 MockCompiler compiler = new MockCompiler.internal( | 103 MockCompiler compiler = new MockCompiler.internal( |
| 103 analyzeAll: analyzeAll, | 104 analyzeAll: analyzeAll, |
| 104 analyzeOnly: analyzeOnly, | 105 analyzeOnly: analyzeOnly, |
| 105 coreSource: coreSource, | 106 coreSource: coreSource, |
| 106 disableInlining: disableInlining, | 107 disableInlining: disableInlining, |
| 107 enableMinification: minify, | 108 enableMinification: minify, |
| 108 trustTypeAnnotations: trustTypeAnnotations, | 109 trustTypeAnnotations: trustTypeAnnotations, |
| 110 enableTypeAssertions: enableTypeAssertions, |
| 109 expectedErrors: expectedErrors, | 111 expectedErrors: expectedErrors, |
| 110 expectedWarnings: expectedWarnings, | 112 expectedWarnings: expectedWarnings, |
| 111 outputProvider: outputProvider); | 113 outputProvider: outputProvider); |
| 112 compiler.registerSource(uri, code); | 114 compiler.registerSource(uri, code); |
| 113 compiler.diagnosticHandler = createHandler(compiler, code); | 115 compiler.diagnosticHandler = createHandler(compiler, code); |
| 114 return compiler; | 116 return compiler; |
| 115 } | 117 } |
| 116 | 118 |
| 117 Future<String> compileAll(String code, | 119 Future<String> compileAll(String code, |
| 118 {Map<String, String> coreSource, | 120 {Map<String, String> coreSource, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 263 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 262 final spaceRe = new RegExp('\\s+'); | 264 final spaceRe = new RegExp('\\s+'); |
| 263 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 265 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 264 if (shouldMatch) { | 266 if (shouldMatch) { |
| 265 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 267 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 266 } else { | 268 } else { |
| 267 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 269 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 268 } | 270 } |
| 269 }); | 271 }); |
| 270 } | 272 } |
| OLD | NEW |