OLD | NEW |
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 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void collect(Uri uri, int begin, int end, String message, kind) { | 76 void collect(Uri uri, int begin, int end, String message, kind) { |
77 if (kind.name == 'verbose info' || kind.name == 'info') { | 77 if (kind.name == 'verbose info' || kind.name == 'info') { |
78 return; | 78 return; |
79 } | 79 } |
80 messages.add(message); | 80 messages.add(message); |
81 } | 81 } |
82 | 82 |
83 Compiler compiler = compilerFor( | 83 Compiler compiler = compilerFor( |
84 example, | 84 example, |
85 diagnosticHandler: collect, | 85 diagnosticHandler: collect, |
86 options: ['--analyze-only']..addAll(kind.options), | 86 options: ['--analyze-only', |
| 87 '--enable-experimental-mirrors']..addAll(kind.options), |
87 cachedCompiler: cachedCompiler); | 88 cachedCompiler: cachedCompiler); |
88 | 89 |
89 return compiler.run(Uri.parse('memory:main.dart')).then((_) { | 90 return compiler.run(Uri.parse('memory:main.dart')).then((_) { |
90 | 91 |
91 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); | 92 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); |
92 | 93 |
93 String expectedText = !kind.hasHowToFix | 94 String expectedText = !kind.hasHowToFix |
94 ? kind.template : '${kind.template}\n${kind.howToFix}'; | 95 ? kind.template : '${kind.template}\n${kind.howToFix}'; |
95 String pattern = expectedText.replaceAllMapped( | 96 String pattern = expectedText.replaceAllMapped( |
96 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); | 97 new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}'); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind)); | 139 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind)); |
139 | 140 |
140 if (!pendingStuff && !compiler.compilerWasCancelled) { | 141 if (!pendingStuff && !compiler.compilerWasCancelled) { |
141 // If there is pending stuff, or the compiler was cancelled, we | 142 // If there is pending stuff, or the compiler was cancelled, we |
142 // shouldn't reuse the compiler. | 143 // shouldn't reuse the compiler. |
143 cachedCompiler = compiler; | 144 cachedCompiler = compiler; |
144 } | 145 } |
145 }); | 146 }); |
146 }).then((_) => cachedCompiler); | 147 }).then((_) => cachedCompiler); |
147 } | 148 } |
OLD | NEW |