| 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 '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 return compiler.run(Uri.parse('memory:main.dart')).then((_) { | 37 return compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 38 | 38 |
| 39 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); | 39 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); |
| 40 | 40 |
| 41 String expectedText = !kind.hasHowToFix | 41 String expectedText = !kind.hasHowToFix |
| 42 ? kind.template : '${kind.template}\n${kind.howToFix}'; | 42 ? kind.template : '${kind.template}\n${kind.howToFix}'; |
| 43 String pattern = expectedText.replaceAllMapped( | 43 String pattern = expectedText.replaceAllMapped( |
| 44 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); | 44 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); |
| 45 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*'); | 45 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*'); |
| 46 | 46 |
| 47 // TODO(johnniwinther): Extend MessageKind to contain information on |
| 48 // where info messages are expected. |
| 49 bool messageFound = false; |
| 47 for (String message in messages) { | 50 for (String message in messages) { |
| 48 Expect.isTrue(new RegExp('^$pattern\$').hasMatch(message), | 51 if (new RegExp('^$pattern\$').hasMatch(message)) { |
| 49 '"$pattern" does not match "$message"'); | 52 messageFound = true; |
| 53 } |
| 50 } | 54 } |
| 55 Expect.isTrue(messageFound, '"$pattern" does not match any in $messages'); |
| 51 return compiler; | 56 return compiler; |
| 52 }); | 57 }); |
| 53 } | 58 } |
| 54 | 59 |
| 55 return cachedCompiler; | 60 return new Future<Compiler>.sync(cachedCompiler); |
| 56 } | 61 } |
| OLD | NEW |