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 SharedMessageKind; | |
12 | 11 |
13 import 'message_kind_helper.dart'; | 12 import 'message_kind_helper.dart'; |
14 | 13 |
15 main(List<String> arguments) { | 14 main(List<String> arguments) { |
16 List<MessageTemplate> examples = <MessageTemplate>[]; | 15 List<MessageTemplate> examples = <MessageTemplate>[]; |
17 List allMessageKinds = [] | 16 for (var kind in MessageKind.values) { |
18 ..addAll(MessageKind.values) | |
19 ..addAll(SharedMessageKind.values); | |
20 for (var kind in allMessageKinds) { | |
21 if (kind == SharedMessageKind.exampleMessage) continue; | |
22 | |
23 MessageTemplate template = MessageTemplate.TEMPLATES[kind]; | 17 MessageTemplate template = MessageTemplate.TEMPLATES[kind]; |
24 Expect.isNotNull(template, "No template for $kind."); | 18 Expect.isNotNull(template, "No template for $kind."); |
25 Expect.equals(kind, template.kind, | 19 Expect.equals(kind, template.kind, |
26 "Invalid MessageTemplate.kind for $kind, found ${template.kind}."); | 20 "Invalid MessageTemplate.kind for $kind, found ${template.kind}."); |
27 | 21 |
28 String name = '${kind.toString()}'.substring('MessageKind.'.length); | 22 String name = '${kind.toString()}'.substring('MessageKind.'.length); |
29 if (!arguments.isEmpty && !arguments.contains(name)) continue; | 23 if (!arguments.isEmpty && !arguments.contains(name)) continue; |
30 if (name == 'GENERIC' // Shouldn't be used. | 24 if (name == 'GENERIC' // Shouldn't be used. |
31 // We can't provoke a crash. | 25 // We can't provoke a crash. |
32 || name == 'COMPILER_CRASHED' | 26 || name == 'COMPILER_CRASHED' |
(...skipping 16 matching lines...) Expand all Loading... |
49 asyncTest(() => Future.forEach(examples, (MessageTemplate template) { | 43 asyncTest(() => Future.forEach(examples, (MessageTemplate template) { |
50 print("Checking '${template.kind}'."); | 44 print("Checking '${template.kind}'."); |
51 Stopwatch sw = new Stopwatch()..start(); | 45 Stopwatch sw = new Stopwatch()..start(); |
52 return check(template, cachedCompiler).then((var compiler) { | 46 return check(template, cachedCompiler).then((var compiler) { |
53 cachedCompiler = compiler; | 47 cachedCompiler = compiler; |
54 sw.stop(); | 48 sw.stop(); |
55 print("Checked '${template.kind}' in ${sw.elapsedMilliseconds}ms."); | 49 print("Checked '${template.kind}' in ${sw.elapsedMilliseconds}ms."); |
56 }); | 50 }); |
57 })); | 51 })); |
58 } | 52 } |
OLD | NEW |