Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: dart/tests/compiler/dart2js/message_kind_helper.dart

Issue 246963005: Change ErrorNode to masquerade as a null literal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r35381 and exception for MessageKind.UNMATCHED_TOKEN. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/compiler/dart2js/message_kind_helper.dart
diff --git a/dart/tests/compiler/dart2js/message_kind_helper.dart b/dart/tests/compiler/dart2js/message_kind_helper.dart
index b8a8fd506b0f1bae7c9d358f3073956d09498aa5..32614015043413b3a9d2f757159889bb0edbfb9f 100644
--- a/dart/tests/compiler/dart2js/message_kind_helper.dart
+++ b/dart/tests/compiler/dart2js/message_kind_helper.dart
@@ -15,6 +15,33 @@ import 'memory_compiler.dart';
const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
+/// Most examples generate a single diagnostic.
+/// Add an exception here if a single diagnostic cannot be produced.
+/// However, consider that a single concise diagnostic is easier to understand,
+/// so try to change error reporting logic before adding an exception.
+final Set<MessageKind> kindsWithExtraMessages = new Set<MessageKind>.from([
+ // See http://dartbug.com/18361.
+ MessageKind.CANNOT_EXTEND_MALFORMED,
+ MessageKind.CANNOT_IMPLEMENT_MALFORMED,
+ MessageKind.CANNOT_MIXIN,
+ MessageKind.CANNOT_MIXIN_MALFORMED,
+ MessageKind.CYCLIC_TYPEDEF_ONE,
+ MessageKind.EQUAL_MAP_ENTRY_KEY,
+ MessageKind.FINAL_FUNCTION_TYPE_PARAMETER,
+ MessageKind.FORMAL_DECLARED_CONST,
+ MessageKind.FORMAL_DECLARED_STATIC,
+ MessageKind.HEX_DIGIT_EXPECTED,
+ MessageKind.HIDDEN_IMPLICIT_IMPORT,
+ MessageKind.HIDDEN_IMPORT,
+ MessageKind.INHERIT_GETTER_AND_METHOD,
+ MessageKind.UNIMPLEMENTED_METHOD,
+ MessageKind.UNIMPLEMENTED_METHOD_ONE,
+ MessageKind.UNTERMINATED_STRING,
+ MessageKind.VAR_FUNCTION_TYPE_PARAMETER,
+ MessageKind.VOID_NOT_ALLOWED,
+ MessageKind.UNMATCHED_TOKEN,
+]);
+
Future<Compiler> check(MessageKind kind, Compiler cachedCompiler) {
Expect.isNotNull(kind.howToFix);
Expect.isFalse(kind.examples.isEmpty);
@@ -30,7 +57,7 @@ Future<Compiler> check(MessageKind kind, Compiler cachedCompiler) {
}
List<String> messages = <String>[];
void collect(Uri uri, int begin, int end, String message, kind) {
- if (kind.name == 'verbose info') {
+ if (kind.name == 'verbose info' || kind.name == 'info') {
return;
}
messages.add(message);
@@ -55,13 +82,26 @@ Future<Compiler> check(MessageKind kind, Compiler cachedCompiler) {
// TODO(johnniwinther): Extend MessageKind to contain information on
// where info messages are expected.
bool messageFound = false;
+ List unexpectedMessages = [];
for (String message in messages) {
- if (new RegExp('^$pattern\$').hasMatch(message)) {
+ if (!messageFound && new RegExp('^$pattern\$').hasMatch(message)) {
messageFound = true;
+ } else {
+ unexpectedMessages.add(message);
}
}
Expect.isTrue(messageFound, '"$pattern" does not match any in $messages');
Expect.isFalse(compiler.hasCrashed);
+ if (!unexpectedMessages.isEmpty) {
+ for (String message in unexpectedMessages) {
+ print("Unexpected message: $message");
+ }
+ if (!kindsWithExtraMessages.contains(kind)) {
+ // Try changing the error reporting logic before adding an exception
+ // to [kindsWithExtraMessages].
+ throw 'Unexpected messages found.';
+ }
+ }
cachedCompiler = compiler;
});
}).then((_) => cachedCompiler);
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698