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