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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart2js.test.message_kind_helper;
6
7 import 'package:expect/expect.dart';
8
9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show
10 Compiler,
11 MessageKind;
12
13 import 'memory_compiler.dart';
14
15 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
16
17 Compiler check(MessageKind kind, Compiler cachedCompiler) {
18 Expect.isNotNull(kind.howToFix);
19 Expect.isFalse(kind.examples.isEmpty);
20
21 for (String example in kind.examples) {
22 List<String> messages = <String>[];
23 void collect(Uri uri, int begin, int end, String message, kind) {
24 if (kind.name == 'verbose info') {
25 return;
26 }
27 messages.add(message);
28 }
29
30 Compiler compiler = compilerFor(
31 {'main.dart': example},
32 diagnosticHandler: collect,
33 options: ['--analyze-only'],
34 cachedCompiler: cachedCompiler);
35
36 compiler.run(Uri.parse('memory:main.dart'));
37
38 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
39
40 String pattern = '${kind.template}\n${kind.howToFix}'.replaceAllMapped(
41 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
42 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
43
44 for (String message in messages) {
45 Expect.isTrue(new RegExp('^$pattern\$').hasMatch(message),
46 '"$pattern" does not match "$message"');
47 }
48 return compiler;
49 }
50 }
OLDNEW
« 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