| 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import 'package:compiler/src/diagnostics/messages.dart' show | 8 import 'package:compiler/src/diagnostics/messages.dart' show |
| 9 MessageKind, | 9 MessageKind, |
| 10 MessageTemplate; | 10 MessageTemplate; |
| 11 | 11 |
| 12 import 'message_kind_helper.dart'; | 12 import 'message_kind_helper.dart'; |
| 13 | 13 |
| 14 main(List<String> arguments) { | 14 main(List<String> arguments) { |
| 15 List<MessageTemplate> examples = <MessageTemplate>[]; | 15 List<MessageTemplate> examples = <MessageTemplate>[]; |
| 16 for (MessageKind kind in MessageKind.values) { | 16 for (MessageKind kind in MessageKind.values) { |
| 17 MessageTemplate template = MessageTemplate.TEMPLATES[kind]; | 17 MessageTemplate template = MessageTemplate.TEMPLATES[kind]; |
| 18 Expect.isNotNull(template, "No template for $kind."); | 18 Expect.isNotNull(template, "No template for $kind."); |
| 19 Expect.equals(kind, template.kind, | 19 Expect.equals(kind, template.kind, |
| 20 "Invalid MessageTemplate.kind for $kind, found ${template.kind}."); | 20 "Invalid MessageTemplate.kind for $kind, found ${template.kind}."); |
| 21 | 21 |
| 22 String name = '${kind.toString()}'.substring('MessageKind.'.length); | 22 String name = '${kind.toString()}'.substring('MessageKind.'.length); |
| 23 if (!arguments.isEmpty && !arguments.contains(name)) continue; | 23 if (!arguments.isEmpty && !arguments.contains(name)) continue; |
| 24 if (name == 'GENERIC' // Shouldn't be used. | 24 if (name == 'GENERIC' // Shouldn't be used. |
| 25 // We can't provoke a crash. | 25 // We can't provoke a crash. |
| 26 || name == 'COMPILER_CRASHED' | 26 || name == 'COMPILER_CRASHED' |
| 27 || name == 'PLEASE_REPORT_THE_CRASH' | 27 || name == 'PLEASE_REPORT_THE_CRASH' |
| 28 // We cannot provide examples for patch errors. | 28 // We cannot provide examples for patch errors. |
| 29 || name.startsWith('PATCH_') | 29 || name.startsWith('PATCH_') |
| 30 || name == 'LIBRARY_NOT_SUPPORTED') continue; | 30 || name == 'LIBRARY_NOT_SUPPORTED' |
| 31 // TODO(johnniwinther): Remove these when [Compiler.reportUnusedCode] is |
| 32 // reenabled. |
| 33 || name == 'UNUSED_METHOD' |
| 34 || name == 'UNUSED_CLASS' |
| 35 || name == 'UNUSED_TYPEDEF') continue; |
| 31 if (template.examples != null) { | 36 if (template.examples != null) { |
| 32 examples.add(template); | 37 examples.add(template); |
| 33 } else { | 38 } else { |
| 34 print("No example in '$name'"); | 39 print("No example in '$name'"); |
| 35 } | 40 } |
| 36 }; | 41 }; |
| 37 var cachedCompiler; | 42 var cachedCompiler; |
| 38 asyncTest(() => Future.forEach(examples, (MessageTemplate template) { | 43 asyncTest(() => Future.forEach(examples, (MessageTemplate template) { |
| 39 print("Checking '${template.kind}'."); | 44 print("Checking '${template.kind}'."); |
| 40 Stopwatch sw = new Stopwatch()..start(); | 45 Stopwatch sw = new Stopwatch()..start(); |
| 41 return check(template, cachedCompiler).then((var compiler) { | 46 return check(template, cachedCompiler).then((var compiler) { |
| 42 cachedCompiler = compiler; | 47 cachedCompiler = compiler; |
| 43 sw.stop(); | 48 sw.stop(); |
| 44 print("Checked '${template.kind}' in ${sw.elapsedMilliseconds}ms."); | 49 print("Checked '${template.kind}' in ${sw.elapsedMilliseconds}ms."); |
| 45 }); | 50 }); |
| 46 })); | 51 })); |
| 47 } | 52 } |
| OLD | NEW |