| 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' show | 9 import 'package:compiler/compiler_new.dart' show |
| 10 CompilerDiagnostics, | 10 CompilerDiagnostics, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 String toString() { | 30 String toString() { |
| 31 return '${message != null ? message.kind : ''}' | 31 return '${message != null ? message.kind : ''}' |
| 32 ':$uri:$begin:$end:$text:$kind'; | 32 ':$uri:$begin:$end:$text:$kind'; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 class DiagnosticCollector implements CompilerDiagnostics { | 36 class DiagnosticCollector implements CompilerDiagnostics { |
| 37 List<CollectedMessage> messages = <CollectedMessage>[]; | 37 List<CollectedMessage> messages = <CollectedMessage>[]; |
| 38 | 38 |
| 39 void call(Uri uri, int begin, int end, String message, Diagnostic kind) { | |
| 40 throw ''; | |
| 41 report(null, uri, begin, end, message, kind); | |
| 42 } | |
| 43 | |
| 44 @override | 39 @override |
| 45 void report(Message message, | 40 void report(Message message, |
| 46 Uri uri, int begin, int end, String text, Diagnostic kind) { | 41 Uri uri, int begin, int end, String text, Diagnostic kind) { |
| 47 messages.add(new CollectedMessage(message, uri, begin, end, text, kind)); | 42 messages.add(new CollectedMessage(message, uri, begin, end, text, kind)); |
| 48 } | 43 } |
| 49 | 44 |
| 50 Iterable<CollectedMessage> filterMessagesByKinds(List<Diagnostic> kinds) { | 45 Iterable<CollectedMessage> filterMessagesByKinds(List<Diagnostic> kinds) { |
| 51 return messages.where( | 46 return messages.where( |
| 52 (CollectedMessage message) => kinds.contains(message.kind)); | 47 (CollectedMessage message) => kinds.contains(message.kind)); |
| 53 } | 48 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 String expectedValue = '${arguments[key]}'; | 180 String expectedValue = '${arguments[key]}'; |
| 186 String foundValue = '${message.arguments[key]}'; | 181 String foundValue = '${message.arguments[key]}'; |
| 187 if (expectedValue != foundValue) { | 182 if (expectedValue != foundValue) { |
| 188 return 'Expected argument $key with value $expectedValue, ' | 183 return 'Expected argument $key with value $expectedValue, ' |
| 189 'found $foundValue.'; | 184 'found $foundValue.'; |
| 190 } | 185 } |
| 191 } | 186 } |
| 192 return null; | 187 return null; |
| 193 }; | 188 }; |
| 194 } | 189 } |
| OLD | NEW |