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/src/elements/elements.dart' | 10 import 'package:compiler/src/elements/elements.dart' |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 expectedErrors: expectedErrors, | 172 expectedErrors: expectedErrors, |
173 expectedWarnings: expectedWarnings); | 173 expectedWarnings: expectedWarnings); |
174 return compiler.run(uri).then((_) { | 174 return compiler.run(uri).then((_) { |
175 lego.Element element = findElement(compiler, name); | 175 lego.Element element = findElement(compiler, name); |
176 return check(compiler, element); | 176 return check(compiler, element); |
177 }); | 177 }); |
178 } | 178 } |
179 | 179 |
180 Future compileSources(Map<String, String> sources, | 180 Future compileSources(Map<String, String> sources, |
181 check(MockCompiler compiler)) { | 181 check(MockCompiler compiler)) { |
182 Uri base = new Uri(scheme: 'source', path: '/'); | 182 Uri base = new Uri(scheme: 'source'); |
183 Uri mainUri = base.resolve('main.dart'); | 183 Uri mainUri = base.resolve('main.dart'); |
184 String mainCode = sources['main.dart']; | 184 String mainCode = sources['main.dart']; |
185 Expect.isNotNull(mainCode, 'No source code found for "main.dart"'); | 185 Expect.isNotNull(mainCode, 'No source code found for "main.dart"'); |
186 MockCompiler compiler = compilerFor(mainCode, mainUri); | 186 MockCompiler compiler = compilerFor(mainCode, mainUri); |
187 sources.forEach((String path, String code) { | 187 sources.forEach((String path, String code) { |
188 if (path == 'main.dart') return; | 188 if (path == 'main.dart') return; |
189 compiler.registerSource(base.resolve(path), code); | 189 compiler.registerSource(base.resolve(path), code); |
190 }); | 190 }); |
191 | 191 |
192 return compiler.run(mainUri).then((_) { | 192 return compiler.run(mainUri).then((_) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 290 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
291 final spaceRe = new RegExp('\\s+'); | 291 final spaceRe = new RegExp('\\s+'); |
292 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 292 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
293 if (shouldMatch) { | 293 if (shouldMatch) { |
294 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 294 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
295 } else { | 295 } else { |
296 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 296 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
297 } | 297 } |
298 }); | 298 }); |
299 } | 299 } |
OLD | NEW |