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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 int expectedErrors, | 120 int expectedErrors, |
121 int expectedWarnings}) { | 121 int expectedWarnings}) { |
122 Uri uri = new Uri(scheme: 'source'); | 122 Uri uri = new Uri(scheme: 'source'); |
123 OutputCollector outputCollector = new OutputCollector(); | 123 OutputCollector outputCollector = new OutputCollector(); |
124 MockCompiler compiler = compilerFor( | 124 MockCompiler compiler = compilerFor( |
125 code, uri, coreSource: coreSource, disableInlining: disableInlining, | 125 code, uri, coreSource: coreSource, disableInlining: disableInlining, |
126 minify: minify, expectedErrors: expectedErrors, | 126 minify: minify, expectedErrors: expectedErrors, |
127 trustTypeAnnotations: trustTypeAnnotations, | 127 trustTypeAnnotations: trustTypeAnnotations, |
128 expectedWarnings: expectedWarnings, | 128 expectedWarnings: expectedWarnings, |
129 outputProvider: outputCollector); | 129 outputProvider: outputCollector); |
| 130 compiler.diagnosticHandler = createHandler(compiler, code); |
130 return compiler.runCompiler(uri).then((_) { | 131 return compiler.runCompiler(uri).then((_) { |
131 Expect.isFalse(compiler.compilationFailed, | 132 Expect.isFalse(compiler.compilationFailed, |
132 'Unexpected compilation error(s): ${compiler.errors}'); | 133 'Unexpected compilation error(s): ${compiler.errors}'); |
133 return outputCollector.getOutput('', 'js'); | 134 return outputCollector.getOutput('', 'js'); |
134 }); | 135 }); |
135 } | 136 } |
136 | 137 |
137 Future compileAndCheck(String code, | 138 Future compileAndCheck(String code, |
138 String name, | 139 String name, |
139 check(MockCompiler compiler, lego.Element element), | 140 check(MockCompiler compiler, lego.Element element), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 259 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
259 final spaceRe = new RegExp('\\s+'); | 260 final spaceRe = new RegExp('\\s+'); |
260 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 261 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
261 if (shouldMatch) { | 262 if (shouldMatch) { |
262 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 263 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
263 } else { | 264 } else { |
264 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 265 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
265 } | 266 } |
266 }); | 267 }); |
267 } | 268 } |
OLD | NEW |