| 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 List<String> examples = <String>[]; | 30 Map<String, bool> examples = <String, bool>{}; |
| 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 } |
| 33 if (name == 'GENERIC' // Shouldn't be used. | 39 if (name == 'GENERIC' // Shouldn't be used. |
| 34 // We can't provoke a crash. | 40 // We can't provoke a crash. |
| 35 || name == 'COMPILER_CRASHED' | 41 || name == 'COMPILER_CRASHED' |
| 36 || name == 'PLEASE_REPORT_THE_CRASH' | 42 || name == 'PLEASE_REPORT_THE_CRASH' |
| 37 // We cannot provide examples for patch errors. | 43 // We cannot provide examples for patch errors. |
| 38 || name.startsWith('PATCH_')) continue; | 44 || name.startsWith('PATCH_')) continue; |
| 39 if (kind.examples != null) { | 45 if (kind.examples != null) { |
| 40 examples.add(name); | 46 examples[name] = expectNoHowToFix; |
| 41 } else { | 47 } else { |
| 42 print("No example in '$name'"); | 48 print("No example in '$name'"); |
| 43 } | 49 } |
| 44 }; | 50 }; |
| 45 var cachedCompiler; | 51 var cachedCompiler; |
| 46 for (String name in examples) { | 52 examples.forEach((String name, bool expectNoHowToFix) { |
| 47 Stopwatch sw = new Stopwatch()..start(); | 53 Stopwatch sw = new Stopwatch()..start(); |
| 48 cachedCompiler = check(kinds[name], cachedCompiler); | 54 cachedCompiler = check(kinds[name], cachedCompiler, |
| 55 expectNoHowToFix: expectNoHowToFix); |
| 49 sw.stop(); | 56 sw.stop(); |
| 50 print("Checked '$name' in ${sw.elapsedMilliseconds}ms."); | 57 print("Checked '$name' in ${sw.elapsedMilliseconds}ms."); |
| 51 } | 58 }); |
| 52 } | 59 } |
| OLD | NEW |