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 '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show | 5 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show |
6 DualKind, | 6 DualKind, |
7 MessageKind; | 7 MessageKind; |
8 | 8 |
9 import 'message_kind_helper.dart'; | 9 import 'message_kind_helper.dart'; |
10 | 10 |
11 import 'dart:mirrors'; | 11 import 'dart:mirrors'; |
12 | 12 |
13 main() { | 13 main() { |
14 ClassMirror cls = reflectClass(MessageKind); | 14 ClassMirror cls = reflectClass(MessageKind); |
15 Map<String, MessageKind> kinds = <String, MessageKind>{}; | 15 Map<String, MessageKind> kinds = <String, MessageKind>{}; |
16 cls.variables.forEach((Symbol name, VariableMirror variable) { | 16 cls.variables.forEach((Symbol name, VariableMirror variable) { |
17 if (variable.isStatic) { | 17 if (variable.isStatic) { |
18 var value = cls.getField(name).reflectee; | 18 var value = cls.getField(name).reflectee; |
19 if (value is MessageKind) { | 19 if (value is MessageKind) { |
20 kinds[MirrorSystem.getName(name)] = value; | 20 kinds[MirrorSystem.getName(name)] = value; |
21 } else if (value is DualKind) { | 21 } else if (value is DualKind) { |
22 kinds['${MirrorSystem.getName(name)}.error'] = value.error; | 22 kinds['${MirrorSystem.getName(name)}.error'] = value.error; |
23 kinds['${MirrorSystem.getName(name)}.warning'] = value.warning; | 23 kinds['${MirrorSystem.getName(name)}.warning'] = value.warning; |
24 } else { | 24 } else { |
25 Expect.fail("Weird static field: '${MirrorSystem.getName(name)}'."); | 25 Expect.fail("Weird static field: '${MirrorSystem.getName(name)}'."); |
26 } | 26 } |
27 } | 27 } |
28 }); | 28 }); |
29 List<String> names = kinds.keys.toList()..sort(); | 29 List<String> names = kinds.keys.toList()..sort(); |
30 Map<String, bool> examples = <String, bool>{}; | 30 List<String> examples = <String>[]; |
31 for (String name in names) { | 31 for (String name in names) { |
32 MessageKind kind = kinds[name]; | 32 MessageKind kind = kinds[name]; |
33 bool expectNoHowToFix = false; | |
34 if (name == 'READ_SCRIPT_ERROR') { | |
35 // For this we can give no how-to-fix since the underlying error is | |
36 // unknown. | |
37 expectNoHowToFix = true; | |
38 } | |
39 if (name == 'GENERIC' // Shouldn't be used. | 33 if (name == 'GENERIC' // Shouldn't be used. |
40 // We can't provoke a crash. | 34 // We can't provoke a crash. |
41 || name == 'COMPILER_CRASHED' | 35 || name == 'COMPILER_CRASHED' |
42 || name == 'PLEASE_REPORT_THE_CRASH' | 36 || name == 'PLEASE_REPORT_THE_CRASH' |
43 // We cannot provide examples for patch errors. | 37 // We cannot provide examples for patch errors. |
44 || name.startsWith('PATCH_')) continue; | 38 || name.startsWith('PATCH_')) continue; |
45 if (kind.examples != null) { | 39 if (kind.examples != null) { |
46 examples[name] = expectNoHowToFix; | 40 examples.add(name); |
47 } else { | 41 } else { |
48 print("No example in '$name'"); | 42 print("No example in '$name'"); |
49 } | 43 } |
50 }; | 44 }; |
51 var cachedCompiler; | 45 var cachedCompiler; |
52 examples.forEach((String name, bool expectNoHowToFix) { | 46 for (String name in examples) { |
53 Stopwatch sw = new Stopwatch()..start(); | 47 Stopwatch sw = new Stopwatch()..start(); |
54 cachedCompiler = check(kinds[name], cachedCompiler, | 48 cachedCompiler = check(kinds[name], cachedCompiler); |
55 expectNoHowToFix: expectNoHowToFix); | |
56 sw.stop(); | 49 sw.stop(); |
57 print("Checked '$name' in ${sw.elapsedMilliseconds}ms."); | 50 print("Checked '$name' in ${sw.elapsedMilliseconds}ms."); |
58 }); | 51 } |
59 } | 52 } |
OLD | NEW |