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 lib; | 5 library lib; |
6 | 6 |
7 @MirrorsUsed(targets: "lib") | 7 @MirrorsUsed(targets: "lib") |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 static staticMethod() => null; | 27 static staticMethod() => null; |
28 | 28 |
29 static var _staticVariable; | 29 static var _staticVariable; |
30 static get _staticGetter => null; | 30 static get _staticGetter => null; |
31 static set _staticSetter(x) => x; | 31 static set _staticSetter(x) => x; |
32 static _staticMethod() => null; | 32 static _staticMethod() => null; |
33 } | 33 } |
34 | 34 |
35 main() { | 35 main() { |
36 ClassMirror cm = reflect(new A<String>()).type; | 36 ClassMirror cm = reflect(new A<String>()).type; |
37 Expect.setEquals( | 37 Expect.setEquals([ |
38 ['Variable(s(_instanceVariable) in s(A), private)', | 38 'Variable(s(_instanceVariable) in s(A), private)', |
39 'Variable(s(_staticVariable) in s(A), private, static)', | 39 'Variable(s(_staticVariable) in s(A), private, static)', |
40 'Variable(s(instanceVariable) in s(A))', | 40 'Variable(s(instanceVariable) in s(A))', |
41 'Variable(s(staticVariable) in s(A), static)'], | 41 'Variable(s(staticVariable) in s(A), static)' |
42 cm.declarations.values | 42 ], cm.declarations.values.where((dm) => dm is VariableMirror).map(stringify), |
43 .where((dm) => dm is VariableMirror).map(stringify), | 43 'variables'); |
44 'variables'); | |
45 | 44 |
46 Expect.setEquals( | 45 Expect.setEquals( |
47 ['Method(s(_instanceGetter) in s(A), private, getter)', | 46 [ |
48 'Method(s(_staticGetter) in s(A), private, static, getter)', | 47 'Method(s(_instanceGetter) in s(A), private, getter)', |
49 'Method(s(instanceGetter) in s(A), getter)', | 48 'Method(s(_staticGetter) in s(A), private, static, getter)', |
50 'Method(s(staticGetter) in s(A), static, getter)'], | 49 'Method(s(instanceGetter) in s(A), getter)', |
51 cm.declarations.values | 50 'Method(s(staticGetter) in s(A), static, getter)' |
52 .where((dm) => dm is MethodMirror && dm.isGetter).map(stringify), | 51 ], |
53 'getters'); | 52 cm.declarations.values |
| 53 .where((dm) => dm is MethodMirror && dm.isGetter) |
| 54 .map(stringify), |
| 55 'getters'); |
54 | 56 |
55 Expect.setEquals( | 57 Expect.setEquals( |
56 ['Method(s(_instanceSetter=) in s(A), private, setter)', | 58 [ |
57 'Method(s(_staticSetter=) in s(A), private, static, setter)', | 59 'Method(s(_instanceSetter=) in s(A), private, setter)', |
58 'Method(s(instanceSetter=) in s(A), setter)', | 60 'Method(s(_staticSetter=) in s(A), private, static, setter)', |
59 'Method(s(staticSetter=) in s(A), static, setter)'], | 61 'Method(s(instanceSetter=) in s(A), setter)', |
60 cm.declarations.values | 62 'Method(s(staticSetter=) in s(A), static, setter)' |
61 .where((dm) => dm is MethodMirror && dm.isSetter).map(stringify), | 63 ], |
62 'setters'); | 64 cm.declarations.values |
| 65 .where((dm) => dm is MethodMirror && dm.isSetter) |
| 66 .map(stringify), |
| 67 'setters'); |
63 | 68 |
64 Expect.setEquals( | 69 Expect.setEquals( |
65 ['Method(s(_instanceMethod) in s(A), private)', | 70 [ |
66 'Method(s(_staticMethod) in s(A), private, static)', | 71 'Method(s(_instanceMethod) in s(A), private)', |
67 'Method(s(instanceMethod) in s(A))', | 72 'Method(s(_staticMethod) in s(A), private, static)', |
68 'Method(s(staticMethod) in s(A), static)'], | 73 'Method(s(instanceMethod) in s(A))', |
69 cm.declarations.values | 74 'Method(s(staticMethod) in s(A), static)' |
70 .where((dm) => dm is MethodMirror && dm.isRegularMethod) | 75 ], |
71 .map(stringify), 'methods'); | 76 cm.declarations.values |
| 77 .where((dm) => dm is MethodMirror && dm.isRegularMethod) |
| 78 .map(stringify), |
| 79 'methods'); |
72 | 80 |
73 Expect.setEquals( | 81 Expect.setEquals( |
74 ['Method(s(A) in s(A), constructor)'], | 82 ['Method(s(A) in s(A), constructor)'], |
75 cm.declarations.values | 83 cm.declarations.values |
76 .where((dm) => dm is MethodMirror && dm.isConstructor).map(stringify), | 84 .where((dm) => dm is MethodMirror && dm.isConstructor) |
77 'constructors'); | 85 .map(stringify), |
| 86 'constructors'); |
78 | 87 |
79 Expect.setEquals( | 88 Expect.setEquals( |
80 ['TypeVariable(s(T) in s(A), upperBound = Class(s(Object) in ' | 89 [ |
81 's(dart.core), top-level))'], | 90 'TypeVariable(s(T) in s(A), upperBound = Class(s(Object) in ' |
82 cm.declarations.values | 91 's(dart.core), top-level))' |
83 .where((dm) => dm is TypeVariableMirror).map(stringify), | 92 ], |
84 'type variables'); | 93 cm.declarations.values |
85 | 94 .where((dm) => dm is TypeVariableMirror) |
86 } | 95 .map(stringify), |
| 96 'type variables'); |
| 97 } |
OLD | NEW |