OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.diagnostic_helper; | 5 library dart2js.test.diagnostic_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:compiler/compiler_new.dart' | 9 import 'package:compiler/compiler_new.dart' |
10 show CompilerDiagnostics, Diagnostic; | 10 show CompilerDiagnostics, Diagnostic; |
(...skipping 17 matching lines...) Expand all Loading... |
28 String toString() { | 28 String toString() { |
29 return '${message != null ? message.kind : ''}' | 29 return '${message != null ? message.kind : ''}' |
30 ':$uri:$begin:$end:$text:$kind'; | 30 ':$uri:$begin:$end:$text:$kind'; |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 class DiagnosticCollector implements CompilerDiagnostics { | 34 class DiagnosticCollector implements CompilerDiagnostics { |
35 List<CollectedMessage> messages = <CollectedMessage>[]; | 35 List<CollectedMessage> messages = <CollectedMessage>[]; |
36 | 36 |
37 @override | 37 @override |
38 void report(Message message, Uri uri, int begin, int end, String text, | 38 void report(covariant Message message, Uri uri, int begin, int end, |
39 Diagnostic kind) { | 39 String text, Diagnostic kind) { |
40 messages.add(new CollectedMessage(message, uri, begin, end, text, kind)); | 40 messages.add(new CollectedMessage(message, uri, begin, end, text, kind)); |
41 } | 41 } |
42 | 42 |
43 Iterable<CollectedMessage> filterMessagesByKinds(List<Diagnostic> kinds) { | 43 Iterable<CollectedMessage> filterMessagesByKinds(List<Diagnostic> kinds) { |
44 return messages | 44 return messages |
45 .where((CollectedMessage message) => kinds.contains(message.kind)); | 45 .where((CollectedMessage message) => kinds.contains(message.kind)); |
46 } | 46 } |
47 | 47 |
48 Iterable<CollectedMessage> get errors { | 48 Iterable<CollectedMessage> get errors { |
49 return filterMessagesByKinds([Diagnostic.ERROR]); | 49 return filterMessagesByKinds([Diagnostic.ERROR]); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 String expectedValue = '${arguments[key]}'; | 178 String expectedValue = '${arguments[key]}'; |
179 String foundValue = '${message.arguments[key]}'; | 179 String foundValue = '${message.arguments[key]}'; |
180 if (expectedValue != foundValue) { | 180 if (expectedValue != foundValue) { |
181 return 'Expected argument $key with value $expectedValue, ' | 181 return 'Expected argument $key with value $expectedValue, ' |
182 'found $foundValue.'; | 182 'found $foundValue.'; |
183 } | 183 } |
184 } | 184 } |
185 return null; | 185 return null; |
186 }; | 186 }; |
187 } | 187 } |
OLD | NEW |