| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 bool messageFound = false; | 107 bool messageFound = false; |
| 108 List unexpectedMessages = []; | 108 List unexpectedMessages = []; |
| 109 for (String message in messages) { | 109 for (String message in messages) { |
| 110 if (!messageFound && new RegExp('^$pattern\$').hasMatch(message)) { | 110 if (!messageFound && new RegExp('^$pattern\$').hasMatch(message)) { |
| 111 messageFound = true; | 111 messageFound = true; |
| 112 } else { | 112 } else { |
| 113 unexpectedMessages.add(message); | 113 unexpectedMessages.add(message); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 Expect.isTrue(messageFound, '"$pattern" does not match any in $messages'); | 116 Expect.isTrue(messageFound, '"$pattern" does not match any in $messages'); |
| 117 Expect.isFalse(compiler.hasCrashed); | 117 Expect.isFalse(compiler.reporter.hasCrashed); |
| 118 if (!unexpectedMessages.isEmpty) { | 118 if (!unexpectedMessages.isEmpty) { |
| 119 for (String message in unexpectedMessages) { | 119 for (String message in unexpectedMessages) { |
| 120 print("Unexpected message: $message"); | 120 print("Unexpected message: $message"); |
| 121 } | 121 } |
| 122 if (!kindsWithExtraMessages.contains(template.kind)) { | 122 if (!kindsWithExtraMessages.contains(template.kind)) { |
| 123 // Try changing the error reporting logic before adding an exception | 123 // Try changing the error reporting logic before adding an exception |
| 124 // to [kindsWithExtraMessages]. | 124 // to [kindsWithExtraMessages]. |
| 125 throw 'Unexpected messages found.'; | 125 throw 'Unexpected messages found.'; |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool pendingStuff = false; | 129 bool pendingStuff = false; |
| 130 for (var e in compiler.resolver.pendingClassesToBePostProcessed) { | 130 for (var e in compiler.resolver.pendingClassesToBePostProcessed) { |
| 131 pendingStuff = true; | 131 pendingStuff = true; |
| 132 compiler.reportInfo( | 132 compiler.reporter.reportInfo( |
| 133 e, MessageKind.GENERIC, | 133 e, MessageKind.GENERIC, |
| 134 {'text': 'Pending class to be post-processed.'}); | 134 {'text': 'Pending class to be post-processed.'}); |
| 135 } | 135 } |
| 136 for (var e in compiler.resolver.pendingClassesToBeResolved) { | 136 for (var e in compiler.resolver.pendingClassesToBeResolved) { |
| 137 pendingStuff = true; | 137 pendingStuff = true; |
| 138 compiler.reportInfo( | 138 compiler.reporter.reportInfo( |
| 139 e, MessageKind.GENERIC, | 139 e, MessageKind.GENERIC, |
| 140 {'text': 'Pending class to be resolved.'}); | 140 {'text': 'Pending class to be resolved.'}); |
| 141 } | 141 } |
| 142 Expect.isTrue(!pendingStuff || | 142 Expect.isTrue(!pendingStuff || |
| 143 kindsWithPendingClasses.contains(template)); | 143 kindsWithPendingClasses.contains(template)); |
| 144 | 144 |
| 145 if (!pendingStuff) { | 145 if (!pendingStuff) { |
| 146 // If there is pending stuff, or the compiler was cancelled, we | 146 // If there is pending stuff, or the compiler was cancelled, we |
| 147 // shouldn't reuse the compiler. | 147 // shouldn't reuse the compiler. |
| 148 cachedCompiler = compiler; | 148 cachedCompiler = compiler; |
| 149 } | 149 } |
| 150 }); | 150 }); |
| 151 }).then((_) => cachedCompiler); | 151 }).then((_) => cachedCompiler); |
| 152 } | 152 } |
| OLD | NEW |