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

Side by Side Diff: tests/compiler/dart2js/message_kind_helper.dart

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 years, 3 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
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 9
9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show
10 Compiler, 11 Compiler,
11 MessageKind; 12 MessageKind;
12 13
13 import 'memory_compiler.dart'; 14 import 'memory_compiler.dart';
14 15
15 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]'; 16 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
16 17
17 Compiler check(MessageKind kind, Compiler cachedCompiler) { 18 Future<Compiler> check(MessageKind kind, Compiler cachedCompiler) {
18 Expect.isNotNull(kind.howToFix); 19 Expect.isNotNull(kind.howToFix);
19 Expect.isFalse(kind.examples.isEmpty); 20 Expect.isFalse(kind.examples.isEmpty);
20 21
21 for (String example in kind.examples) { 22 for (String example in kind.examples) {
22 List<String> messages = <String>[]; 23 List<String> messages = <String>[];
23 void collect(Uri uri, int begin, int end, String message, kind) { 24 void collect(Uri uri, int begin, int end, String message, kind) {
24 if (kind.name == 'verbose info') { 25 if (kind.name == 'verbose info') {
25 return; 26 return;
26 } 27 }
27 messages.add(message); 28 messages.add(message);
28 } 29 }
29 30
30 Compiler compiler = compilerFor( 31 Compiler compiler = compilerFor(
31 {'main.dart': example}, 32 {'main.dart': example},
32 diagnosticHandler: collect, 33 diagnosticHandler: collect,
33 options: ['--analyze-only'], 34 options: ['--analyze-only'],
34 cachedCompiler: cachedCompiler); 35 cachedCompiler: cachedCompiler);
35 36
36 compiler.run(Uri.parse('memory:main.dart')); 37 return compiler.run(Uri.parse('memory:main.dart')).then((_) {
37 38
38 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); 39 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
39 40
40 String expectedText = !kind.hasHowToFix 41 String expectedText = !kind.hasHowToFix
41 ? kind.template : '${kind.template}\n${kind.howToFix}'; 42 ? kind.template : '${kind.template}\n${kind.howToFix}';
42 String pattern = expectedText.replaceAllMapped( 43 String pattern = expectedText.replaceAllMapped(
43 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); 44 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
44 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*'); 45 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
45 46
46 for (String message in messages) { 47 for (String message in messages) {
47 Expect.isTrue(new RegExp('^$pattern\$').hasMatch(message), 48 Expect.isTrue(new RegExp('^$pattern\$').hasMatch(message),
48 '"$pattern" does not match "$message"'); 49 '"$pattern" does not match "$message"');
49 } 50 }
50 cachedCompiler = compiler; 51 return compiler;
52 });
51 } 53 }
52 54
53 return cachedCompiler; 55 return cachedCompiler;
54 } 56 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/memory_source_file_helper.dart ('k') | tests/compiler/dart2js/message_kind_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698