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, |
11 Diagnostic; | 11 Diagnostic; |
12 import 'package:compiler/src/diagnostics/messages.dart' show | 12 import 'package:compiler/src/diagnostics/messages.dart' show |
13 Message, | 13 Message, |
14 MessageKind; | 14 MessageKind; |
15 import 'package:expect/expect.dart'; | 15 import 'package:expect/expect.dart'; |
16 | 16 |
17 class CollectedMessage { | 17 class CollectedMessage { |
18 final Message message; | 18 final Message message; |
19 final Uri uri; | 19 final Uri uri; |
20 final int begin; | 20 final int begin; |
21 final int end; | 21 final int end; |
22 final String text; | 22 final String text; |
23 final Diagnostic kind; | 23 final Diagnostic kind; |
24 | 24 |
25 CollectedMessage( | 25 CollectedMessage( |
26 this.message, this.uri, this.begin, this.end, this.text, this.kind); | 26 this.message, this.uri, this.begin, this.end, this.text, this.kind); |
27 | 27 |
28 MessageKind get messageKind => message.kind; | 28 MessageKind get messageKind => message?.kind; |
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 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 String expectedValue = '${arguments[key]}'; | 185 String expectedValue = '${arguments[key]}'; |
186 String foundValue = '${message.arguments[key]}'; | 186 String foundValue = '${message.arguments[key]}'; |
187 if (expectedValue != foundValue) { | 187 if (expectedValue != foundValue) { |
188 return 'Expected argument $key with value $expectedValue, ' | 188 return 'Expected argument $key with value $expectedValue, ' |
189 'found $foundValue.'; | 189 'found $foundValue.'; |
190 } | 190 } |
191 } | 191 } |
192 return null; | 192 return null; |
193 }; | 193 }; |
194 } | 194 } |
OLD | NEW |