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/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 /// Most messages can be tested without causing a fatal error. Add an exception | 51 /// Most messages can be tested without causing a fatal error. Add an exception |
52 /// here if a fatal error is unavoidable and leads to pending classes. | 52 /// here if a fatal error is unavoidable and leads to pending classes. |
53 /// Try to avoid adding exceptions here; a fatal error causes the compiler to | 53 /// Try to avoid adding exceptions here; a fatal error causes the compiler to |
54 /// stop before analyzing all input, and it isn't safe to reuse it. | 54 /// stop before analyzing all input, and it isn't safe to reuse it. |
55 final Set<MessageKind> kindsWithPendingClasses = new Set<MessageKind>.from([ | 55 final Set<MessageKind> kindsWithPendingClasses = new Set<MessageKind>.from([ |
56 // If you add something here, please file a *new* bug report. | 56 // If you add something here, please file a *new* bug report. |
57 ]); | 57 ]); |
58 | 58 |
59 Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) { | 59 Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) { |
60 Expect.isNotNull(template.howToFix); | |
61 Expect.isFalse(template.examples.isEmpty); | 60 Expect.isFalse(template.examples.isEmpty); |
62 | 61 |
63 return Future.forEach(template.examples, (example) { | 62 return Future.forEach(template.examples, (example) { |
64 if (example is String) { | 63 if (example is String) { |
65 example = {'main.dart': example}; | 64 example = {'main.dart': example}; |
66 } else { | 65 } else { |
67 Expect.isTrue(example is Map, | 66 Expect.isTrue(example is Map, |
68 "Example must be either a String or a Map."); | 67 "Example must be either a String or a Map."); |
69 Expect.isTrue(example.containsKey('main.dart'), | 68 Expect.isTrue(example.containsKey('main.dart'), |
70 "Example map must contain a 'main.dart' entry."); | 69 "Example map must contain a 'main.dart' entry."); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 kindsWithPendingClasses.contains(template)); | 153 kindsWithPendingClasses.contains(template)); |
155 | 154 |
156 if (!pendingStuff) { | 155 if (!pendingStuff) { |
157 // If there is pending stuff, or the compiler was cancelled, we | 156 // If there is pending stuff, or the compiler was cancelled, we |
158 // shouldn't reuse the compiler. | 157 // shouldn't reuse the compiler. |
159 cachedCompiler = compiler; | 158 cachedCompiler = compiler; |
160 } | 159 } |
161 }); | 160 }); |
162 }).then((_) => cachedCompiler); | 161 }).then((_) => cachedCompiler); |
163 } | 162 } |
OLD | NEW |