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

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

Issue 1423623008: Improve messages and static use for super/this-calls. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 5 years, 1 month 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 | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/message_kind_helper.dart
diff --git a/tests/compiler/dart2js/message_kind_helper.dart b/tests/compiler/dart2js/message_kind_helper.dart
index 9d60632dd3a5bc82b4cb7f5b70f883e279aedb72..1499cf5851053791256919b2f98d790e619c5b18 100644
--- a/tests/compiler/dart2js/message_kind_helper.dart
+++ b/tests/compiler/dart2js/message_kind_helper.dart
@@ -15,8 +15,8 @@ import 'package:compiler/src/dart_backend/dart_backend.dart' show
import 'package:compiler/src/diagnostics/messages.dart' show
MessageKind,
MessageTemplate;
-import 'package:compiler/src/old_to_new_api.dart' show
- LegacyCompilerDiagnostics;
+import 'package:compiler/compiler_new.dart' show
+ Diagnostic;
import 'memory_compiler.dart';
@@ -68,13 +68,7 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
Expect.isTrue(example.containsKey('main.dart'),
"Example map must contain a 'main.dart' entry.");
}
- List<String> messages = <String>[];
- void collect(Uri uri, int begin, int end, String message, kind) {
- if (kind.name == 'verbose info' || kind.name == 'info') {
- return;
- }
- messages.add(message);
- }
+ DiagnosticCollector collector = new DiagnosticCollector();
bool oldBackendIsDart;
if (cachedCompiler != null) {
@@ -84,7 +78,7 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
Compiler compiler = compilerFor(
memorySourceFiles: example,
- diagnosticHandler: new LegacyCompilerDiagnostics(collect),
+ diagnosticHandler: collector,
options: [Flags.analyzeOnly,
Flags.enableExperimentalMirrors]..addAll(template.options),
cachedCompiler:
@@ -93,6 +87,11 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
oldBackendIsDart == newBackendIsDart ? cachedCompiler : null);
return compiler.run(Uri.parse('memory:main.dart')).then((_) {
+ Iterable<DiagnosticMessage> messages = collector.filterMessagesByKinds(
+ [Diagnostic.ERROR,
+ Diagnostic.WARNING,
+ Diagnostic.HINT,
+ Diagnostic.CRASH]);
Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
@@ -102,21 +101,31 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
+ bool checkMessage(DiagnosticMessage message) {
+ if (message.message.kind != MessageKind.GENERIC) {
+ return message.message.kind == template.kind;
+ } else {
+ return new RegExp('^$pattern\$').hasMatch(message.text);
+ }
+ }
+
// TODO(johnniwinther): Extend MessageKind to contain information on
// where info messages are expected.
bool messageFound = false;
List unexpectedMessages = [];
- for (String message in messages) {
- if (!messageFound && new RegExp('^$pattern\$').hasMatch(message)) {
+ for (DiagnosticMessage message in messages) {
+ if (!messageFound && checkMessage(message)) {
messageFound = true;
} else {
unexpectedMessages.add(message);
}
}
- Expect.isTrue(messageFound, '"$pattern" does not match any in $messages');
+ Expect.isTrue(messageFound,
+ '${template.kind}} does not match any in\n '
+ '${messages.join('\n ')}');
Expect.isFalse(compiler.reporter.hasCrashed);
if (!unexpectedMessages.isEmpty) {
- for (String message in unexpectedMessages) {
+ for (DiagnosticMessage message in unexpectedMessages) {
print("Unexpected message: $message");
}
if (!kindsWithExtraMessages.contains(template.kind)) {
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698