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

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

Issue 21242002: Retain elements a finer granularity than library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 years, 4 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..f972a96fc57cf96bb752a8e8e42f6e49c1c3c1ee
--- /dev/null
+++ b/dart/tests/compiler/dart2js/message_kind_helper.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart2js.test.message_kind_helper;
+
+import 'package:expect/expect.dart';
+
+import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show
+ Compiler,
+ MessageKind;
+
+import 'memory_compiler.dart';
+
+const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
+
+Compiler check(MessageKind kind, Compiler cachedCompiler) {
+ Expect.isNotNull(kind.howToFix);
+ Expect.isFalse(kind.examples.isEmpty);
+
+ for (String example in kind.examples) {
+ List<String> messages = <String>[];
+ void collect(Uri uri, int begin, int end, String message, kind) {
+ if (kind.name == 'verbose info') {
+ return;
+ }
+ messages.add(message);
+ }
+
+ Compiler compiler = compilerFor(
+ {'main.dart': example},
+ diagnosticHandler: collect,
+ options: ['--analyze-only'],
+ cachedCompiler: cachedCompiler);
+
+ compiler.run(Uri.parse('memory:main.dart'));
+
+ Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
+
+ String pattern = '${kind.template}\n${kind.howToFix}'.replaceAllMapped(
+ new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
+ pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
+
+ for (String message in messages) {
+ Expect.isTrue(new RegExp('^$pattern\$').hasMatch(message),
+ '"$pattern" does not match "$message"');
+ }
+ return compiler;
+ }
+}
« no previous file with comments | « dart/tests/compiler/dart2js/memory_compiler.dart ('k') | dart/tests/compiler/dart2js/message_kind_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698