| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.test.message_kind_helper; | 5 library dart2js.test.message_kind_helper; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 import 'package:compiler/src/dart2jslib.dart' show | 10 import 'package:compiler/src/dart2jslib.dart' show |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 void collect(Uri uri, int begin, int end, String message, kind) { | 76 void collect(Uri uri, int begin, int end, String message, kind) { |
| 77 if (kind.name == 'verbose info' || kind.name == 'info') { | 77 if (kind.name == 'verbose info' || kind.name == 'info') { |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 messages.add(message); | 80 messages.add(message); |
| 81 } | 81 } |
| 82 | 82 |
| 83 Compiler compiler = compilerFor( | 83 Compiler compiler = compilerFor( |
| 84 example, | 84 example, |
| 85 diagnosticHandler: collect, | 85 diagnosticHandler: collect, |
| 86 options: ['--analyze-only', | 86 options: ['--analyze-only']..addAll(kind.options), |
| 87 '--enable-experimental-mirrors']..addAll(kind.options), | |
| 88 cachedCompiler: cachedCompiler); | 87 cachedCompiler: cachedCompiler); |
| 89 | 88 |
| 90 return compiler.run(Uri.parse('memory:main.dart')).then((_) { | 89 return compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 91 | 90 |
| 92 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); | 91 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); |
| 93 | 92 |
| 94 String expectedText = !kind.hasHowToFix | 93 String expectedText = !kind.hasHowToFix |
| 95 ? kind.template : '${kind.template}\n${kind.howToFix}'; | 94 ? kind.template : '${kind.template}\n${kind.howToFix}'; |
| 96 String pattern = expectedText.replaceAllMapped( | 95 String pattern = expectedText.replaceAllMapped( |
| 97 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); | 96 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind)); | 138 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind)); |
| 140 | 139 |
| 141 if (!pendingStuff && !compiler.compilerWasCancelled) { | 140 if (!pendingStuff && !compiler.compilerWasCancelled) { |
| 142 // If there is pending stuff, or the compiler was cancelled, we | 141 // If there is pending stuff, or the compiler was cancelled, we |
| 143 // shouldn't reuse the compiler. | 142 // shouldn't reuse the compiler. |
| 144 cachedCompiler = compiler; | 143 cachedCompiler = compiler; |
| 145 } | 144 } |
| 146 }); | 145 }); |
| 147 }).then((_) => cachedCompiler); | 146 }).then((_) => cachedCompiler); |
| 148 } | 147 } |
| OLD | NEW |