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 test.immutable_collections; | 5 library test.immutable_collections; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 someException(e) => e is Exception || e is Error; | 10 someException(e) => e is Exception || e is Error; |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 checkMethod(MethodMirror mm) { | 36 checkMethod(MethodMirror mm) { |
37 checkList(mm.parameters, 'MethodMirror.parameters'); | 37 checkList(mm.parameters, 'MethodMirror.parameters'); |
38 checkList(mm.metadata, 'MethodMirror.metadata'); | 38 checkList(mm.metadata, 'MethodMirror.metadata'); |
39 | 39 |
40 mm.parameters.forEach(checkParameter); | 40 mm.parameters.forEach(checkParameter); |
41 } | 41 } |
42 | 42 |
43 checkClass(ClassMirror cm) { | 43 checkClass(ClassMirror cm) { |
44 checkMap(cm.declarations, 'ClassMirror.declarations'); | 44 checkMap(cm.members, 'ClassMirror.members'); |
| 45 checkMap(cm.variables, 'ClassMirror.variables'); |
| 46 checkMap(cm.methods, 'ClassMirror.methods'); |
| 47 checkMap(cm.getters, 'ClassMirror.getters'); |
| 48 checkMap(cm.setters, 'ClassMirror.setters'); |
| 49 checkMap(cm.constructors, 'ClassMirror.constructors'); |
45 checkList(cm.metadata, 'ClassMirror.metadata'); | 50 checkList(cm.metadata, 'ClassMirror.metadata'); |
46 checkList(cm.superinterfaces, 'ClassMirror.superinterfaces'); | 51 checkList(cm.superinterfaces, 'ClassMirror.superinterfaces'); |
47 checkList(cm.typeArguments, 'ClassMirror.typeArguments'); | 52 checkList(cm.typeArguments, 'ClassMirror.typeArguments'); |
48 checkList(cm.typeVariables, 'ClassMirror.typeVariables'); | 53 checkList(cm.typeVariables, 'ClassMirror.typeVariables'); |
49 | 54 |
50 cm.declarations.values.forEach(checkDeclaration); | 55 cm.methods.values.forEach(checkMethod); |
| 56 cm.getters.values.forEach(checkMethod); |
| 57 cm.setters.values.forEach(checkMethod); |
| 58 cm.constructors.values.forEach(checkMethod); |
| 59 cm.variables.values.forEach(checkVariable); |
51 cm.typeVariables.forEach(checkTypeVariable); | 60 cm.typeVariables.forEach(checkTypeVariable); |
52 } | 61 } |
53 | 62 |
54 checkType(TypeMirror tm) { | 63 checkType(TypeMirror tm) { |
55 checkList(tm.metadata, 'TypeMirror.metadata'); | 64 checkList(tm.metadata, 'TypeMirror.metadata'); |
56 } | 65 } |
57 | 66 |
58 checkDeclaration(DeclarationMirror dm) { | |
59 if (dm is MethodMirror) checkMethod(dm); | |
60 if (dm is ClassMirror) checkClass(dm); | |
61 if (dm is TypeMirror) checkType(dm); | |
62 if (dm is VariableMirror) checkVariable(dm); | |
63 if (dm is TypeVariableMirror) checkTypeVariable(dm); | |
64 } | |
65 | |
66 checkLibrary(LibraryMirror lm) { | 67 checkLibrary(LibraryMirror lm) { |
67 checkMap(lm.declarations, 'LibraryMirror.declarations'); | 68 checkMap(lm.members, 'LibraryMirror.members'); |
| 69 checkMap(lm.variables, 'LibraryMirror.variables'); |
| 70 checkMap(lm.classes, 'LibraryMirror.classes'); |
| 71 checkMap(lm.types, 'LibraryMirror.types'); |
| 72 checkMap(lm.functions, 'LibraryMirror.functions'); |
| 73 checkMap(lm.getters, 'LibraryMirror.getters'); |
| 74 checkMap(lm.setters, 'LibraryMirror.setters'); |
68 checkList(lm.metadata, 'LibraryMirror.metadata'); | 75 checkList(lm.metadata, 'LibraryMirror.metadata'); |
69 | 76 |
70 lm.declarations.values.forEach(checkDeclaration); | 77 lm.types.values.forEach(checkType); |
| 78 lm.classes.values.forEach(checkClass); |
| 79 lm.functions.values.forEach(checkMethod); |
| 80 lm.getters.values.forEach(checkMethod); |
| 81 lm.setters.values.forEach(checkMethod); |
| 82 lm.variables.values.forEach(checkVariable); |
71 } | 83 } |
72 | 84 |
73 main() { | 85 main() { |
74 currentMirrorSystem().libraries.values.forEach(checkLibrary); | 86 currentMirrorSystem().libraries.values.forEach(checkLibrary); |
75 checkType(currentMirrorSystem().voidType); | 87 checkType(currentMirrorSystem().voidType); |
76 checkType(currentMirrorSystem().dynamicType); | 88 checkType(currentMirrorSystem().dynamicType); |
77 } | 89 } |
OLD | NEW |