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

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

Issue 1148343004: Remove ConstantExpression.value (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Update comments. Created 5 years, 6 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
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/metadata_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:async';
9 9
10 import 'package:compiler/src/dart2jslib.dart' show 10 import 'package:compiler/src/dart2jslib.dart' show
11 Compiler, 11 Compiler,
12 MessageKind; 12 MessageKind;
13 import 'package:compiler/src/dart_backend/dart_backend.dart' show
14 DartBackend;
13 15
14 import 'memory_compiler.dart'; 16 import 'memory_compiler.dart';
15 17
16 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]'; 18 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
17 19
18 /// Most examples generate a single diagnostic. 20 /// Most examples generate a single diagnostic.
19 /// Add an exception here if a single diagnostic cannot be produced. 21 /// Add an exception here if a single diagnostic cannot be produced.
20 /// However, consider that a single concise diagnostic is easier to understand, 22 /// However, consider that a single concise diagnostic is easier to understand,
21 /// so try to change error reporting logic before adding an exception. 23 /// so try to change error reporting logic before adding an exception.
22 final Set<MessageKind> kindsWithExtraMessages = new Set<MessageKind>.from([ 24 final Set<MessageKind> kindsWithExtraMessages = new Set<MessageKind>.from([
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 "Example map must contain a 'main.dart' entry."); 64 "Example map must contain a 'main.dart' entry.");
63 } 65 }
64 List<String> messages = <String>[]; 66 List<String> messages = <String>[];
65 void collect(Uri uri, int begin, int end, String message, kind) { 67 void collect(Uri uri, int begin, int end, String message, kind) {
66 if (kind.name == 'verbose info' || kind.name == 'info') { 68 if (kind.name == 'verbose info' || kind.name == 'info') {
67 return; 69 return;
68 } 70 }
69 messages.add(message); 71 messages.add(message);
70 } 72 }
71 73
74 bool oldBackendIsDart;
75 if (cachedCompiler != null) {
76 oldBackendIsDart = cachedCompiler.backend is DartBackend;
77 }
78 bool newBackendIsDart = kind.options.contains('--output-type=dart');
79
72 Compiler compiler = compilerFor( 80 Compiler compiler = compilerFor(
73 example, 81 example,
74 diagnosticHandler: collect, 82 diagnosticHandler: collect,
75 options: ['--analyze-only', 83 options: ['--analyze-only',
76 '--enable-experimental-mirrors']..addAll(kind.options), 84 '--enable-experimental-mirrors']..addAll(kind.options),
77 cachedCompiler: cachedCompiler); 85 cachedCompiler:
86 // TODO(johnniwinther): Remove this restriction when constant
87 // values can be computed directly from the expressions.
88 oldBackendIsDart == newBackendIsDart ? cachedCompiler : null);
78 89
79 return compiler.run(Uri.parse('memory:main.dart')).then((_) { 90 return compiler.run(Uri.parse('memory:main.dart')).then((_) {
80 91
81 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); 92 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
82 93
83 String expectedText = !kind.hasHowToFix 94 String expectedText = !kind.hasHowToFix
84 ? kind.template : '${kind.template}\n${kind.howToFix}'; 95 ? kind.template : '${kind.template}\n${kind.howToFix}';
85 String pattern = expectedText.replaceAllMapped( 96 String pattern = expectedText.replaceAllMapped(
86 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); 97 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
87 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*'); 98 pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind)); 137 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind));
127 138
128 if (!pendingStuff) { 139 if (!pendingStuff) {
129 // If there is pending stuff, or the compiler was cancelled, we 140 // If there is pending stuff, or the compiler was cancelled, we
130 // shouldn't reuse the compiler. 141 // shouldn't reuse the compiler.
131 cachedCompiler = compiler; 142 cachedCompiler = compiler;
132 } 143 }
133 }); 144 });
134 }).then((_) => cachedCompiler); 145 }).then((_) => cachedCompiler);
135 } 146 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698