| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 OutputCollector outputCollector = new OutputCollector(); | 141 OutputCollector outputCollector = new OutputCollector(); |
| 142 MockCompiler compiler = compilerFor( | 142 MockCompiler compiler = compilerFor( |
| 143 code, uri, coreSource: coreSource, disableInlining: disableInlining, | 143 code, uri, coreSource: coreSource, disableInlining: disableInlining, |
| 144 minify: minify, expectedErrors: expectedErrors, | 144 minify: minify, expectedErrors: expectedErrors, |
| 145 trustTypeAnnotations: trustTypeAnnotations, | 145 trustTypeAnnotations: trustTypeAnnotations, |
| 146 expectedWarnings: expectedWarnings, | 146 expectedWarnings: expectedWarnings, |
| 147 outputProvider: outputCollector); | 147 outputProvider: outputCollector); |
| 148 compiler.diagnosticHandler = createHandler(compiler, code); | 148 compiler.diagnosticHandler = createHandler(compiler, code); |
| 149 return compiler.run(uri).then((compilationSucceded) { | 149 return compiler.run(uri).then((compilationSucceded) { |
| 150 Expect.isTrue(compilationSucceded, | 150 Expect.isTrue(compilationSucceded, |
| 151 'Unexpected compilation error(s): ${compiler.errors}'); | 151 'Unexpected compilation error(s): ' |
| 152 '${compiler.diagnosticCollector.errors}'); |
| 152 return outputCollector.getOutput('', 'js'); | 153 return outputCollector.getOutput('', 'js'); |
| 153 }); | 154 }); |
| 154 } | 155 } |
| 155 | 156 |
| 156 Future compileAndCheck(String code, | 157 Future compileAndCheck(String code, |
| 157 String name, | 158 String name, |
| 158 check(MockCompiler compiler, lego.Element element), | 159 check(MockCompiler compiler, lego.Element element), |
| 159 {int expectedErrors, int expectedWarnings}) { | 160 {int expectedErrors, int expectedWarnings}) { |
| 160 Uri uri = new Uri(scheme: 'source'); | 161 Uri uri = new Uri(scheme: 'source'); |
| 161 MockCompiler compiler = compilerFor(code, uri, | 162 MockCompiler compiler = compilerFor(code, uri, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 281 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 281 final spaceRe = new RegExp('\\s+'); | 282 final spaceRe = new RegExp('\\s+'); |
| 282 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 283 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 283 if (shouldMatch) { | 284 if (shouldMatch) { |
| 284 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 285 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 285 } else { | 286 } else { |
| 286 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 287 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 287 } | 288 } |
| 288 }); | 289 }); |
| 289 } | 290 } |
| OLD | NEW |