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.initializing_formals; | 5 library test.initializing_formals; |
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 class Class<T> { | 10 class Class<T> { |
(...skipping 14 matching lines...) Expand all Loading... |
25 Class.withDynamic(dynamic this.intField); | 25 Class.withDynamic(dynamic this.intField); |
26 } | 26 } |
27 | 27 |
28 class Constant { | 28 class Constant { |
29 final num value; | 29 final num value; |
30 const Constant(this.value); | 30 const Constant(this.value); |
31 const Constant.marked(final this.value); | 31 const Constant.marked(final this.value); |
32 } | 32 } |
33 | 33 |
34 main() { | 34 main() { |
| 35 MethodMirror mm; |
35 ParameterMirror pm; | 36 ParameterMirror pm; |
36 | 37 |
37 pm = reflectClass(Class).constructors[#Class.nongeneric].parameters.single; | 38 mm = reflectClass(Class).declarations[#Class.nongeneric]; |
| 39 pm = mm.parameters.single; |
38 Expect.equals(#intField, pm.simpleName); | 40 Expect.equals(#intField, pm.simpleName); |
39 Expect.equals(reflectClass(int), pm.type); | 41 Expect.equals(reflectClass(int), pm.type); |
40 Expect.isFalse(pm.isNamed); /// 01: ok | 42 Expect.isFalse(pm.isNamed); /// 01: ok |
41 Expect.isFalse(pm.isFinal); /// 01: ok | 43 Expect.isFalse(pm.isFinal); /// 01: ok |
42 Expect.isFalse(pm.isOptional); /// 01: ok | 44 Expect.isFalse(pm.isOptional); /// 01: ok |
43 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 45 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
44 Expect.isFalse(pm.isPrivate); | 46 Expect.isFalse(pm.isPrivate); |
45 Expect.isFalse(pm.isStatic); | 47 Expect.isFalse(pm.isStatic); |
46 Expect.isFalse(pm.isTopLevel); | 48 Expect.isFalse(pm.isTopLevel); |
47 | 49 |
48 pm = reflectClass(Class).constructors[#Class.named].parameters.single; | 50 mm = reflectClass(Class).declarations[#Class.named]; |
| 51 pm = mm.parameters.single; |
49 Expect.equals(#boolField, pm.simpleName); | 52 Expect.equals(#boolField, pm.simpleName); |
50 Expect.equals(reflectClass(bool), pm.type); | 53 Expect.equals(reflectClass(bool), pm.type); |
51 Expect.isTrue(pm.isNamed); /// 01: ok | 54 Expect.isTrue(pm.isNamed); /// 01: ok |
52 Expect.isFalse(pm.isFinal); /// 01: ok | 55 Expect.isFalse(pm.isFinal); /// 01: ok |
53 Expect.isTrue(pm.isOptional); /// 01: ok | 56 Expect.isTrue(pm.isOptional); /// 01: ok |
54 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 57 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
55 Expect.isFalse(pm.isPrivate); | 58 Expect.isFalse(pm.isPrivate); |
56 Expect.isFalse(pm.isStatic); | 59 Expect.isFalse(pm.isStatic); |
57 Expect.isFalse(pm.isTopLevel); | 60 Expect.isFalse(pm.isTopLevel); |
58 | 61 |
59 pm = reflectClass(Class).constructors[#Class.optPos].parameters.single; | 62 mm = reflectClass(Class).declarations[#Class.optPos]; |
| 63 pm = mm.parameters.single; |
60 Expect.equals(#stringField, pm.simpleName); | 64 Expect.equals(#stringField, pm.simpleName); |
61 Expect.equals(reflectClass(String), pm.type); | 65 Expect.equals(reflectClass(String), pm.type); |
62 Expect.isFalse(pm.isNamed); /// 01: ok | 66 Expect.isFalse(pm.isNamed); /// 01: ok |
63 Expect.isFalse(pm.isFinal); /// 01: ok | 67 Expect.isFalse(pm.isFinal); /// 01: ok |
64 Expect.isTrue(pm.isOptional); /// 01: ok | 68 Expect.isTrue(pm.isOptional); /// 01: ok |
65 Expect.isTrue(pm.hasDefaultValue); /// 01: ok | 69 Expect.isTrue(pm.hasDefaultValue); /// 01: ok |
66 Expect.equals('default', pm.defaultValue.reflectee); /// 01: ok | 70 Expect.equals('default', pm.defaultValue.reflectee); /// 01: ok |
67 Expect.isFalse(pm.isPrivate); | 71 Expect.isFalse(pm.isPrivate); |
68 Expect.isFalse(pm.isStatic); | 72 Expect.isFalse(pm.isStatic); |
69 Expect.isFalse(pm.isTopLevel); | 73 Expect.isFalse(pm.isTopLevel); |
70 | 74 |
71 pm = reflectClass(Class).constructors[#Class.generic].parameters.single; | 75 mm = reflectClass(Class).declarations[#Class.generic]; |
| 76 pm = mm.parameters.single; |
72 Expect.equals(#tField, pm.simpleName); | 77 Expect.equals(#tField, pm.simpleName); |
73 Expect.equals(reflectClass(Class).typeVariables.single, pm.type); /// 02: ok | 78 Expect.equals(reflectClass(Class).typeVariables.single, pm.type); /// 02: ok |
74 Expect.isFalse(pm.isNamed); /// 01: ok | 79 Expect.isFalse(pm.isNamed); /// 01: ok |
75 Expect.isFalse(pm.isFinal); /// 01: ok | 80 Expect.isFalse(pm.isFinal); /// 01: ok |
76 Expect.isFalse(pm.isOptional); /// 01: ok | 81 Expect.isFalse(pm.isOptional); /// 01: ok |
77 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 82 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
78 Expect.isFalse(pm.isPrivate); | 83 Expect.isFalse(pm.isPrivate); |
79 Expect.isFalse(pm.isStatic); | 84 Expect.isFalse(pm.isStatic); |
80 Expect.isFalse(pm.isTopLevel); | 85 Expect.isFalse(pm.isTopLevel); |
81 | 86 |
82 pm = reflectClass(Class).constructors[#Class.private].parameters.single; | 87 mm = reflectClass(Class).declarations[#Class.private]; |
| 88 pm = mm.parameters.single; |
83 Expect.equals(#_privateField, pm.simpleName); /// 03: ok | 89 Expect.equals(#_privateField, pm.simpleName); /// 03: ok |
84 Expect.equals(currentMirrorSystem().dynamicType, pm.type); | 90 Expect.equals(currentMirrorSystem().dynamicType, pm.type); |
85 Expect.isFalse(pm.isNamed); /// 01: ok | 91 Expect.isFalse(pm.isNamed); /// 01: ok |
86 Expect.isFalse(pm.isFinal); /// 01: ok | 92 Expect.isFalse(pm.isFinal); /// 01: ok |
87 Expect.isFalse(pm.isOptional); /// 01: ok | 93 Expect.isFalse(pm.isOptional); /// 01: ok |
88 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 94 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
89 Expect.isTrue(pm.isPrivate); | 95 Expect.isTrue(pm.isPrivate); |
90 Expect.isFalse(pm.isStatic); | 96 Expect.isFalse(pm.isStatic); |
91 Expect.isFalse(pm.isTopLevel); | 97 Expect.isFalse(pm.isTopLevel); |
92 | 98 |
93 pm = reflectClass(Class).constructors[#Class.explicitType].parameters.single; | 99 mm = reflectClass(Class).declarations[#Class.explicitType]; |
| 100 pm = mm.parameters.single; |
94 Expect.equals(#intField, pm.simpleName); | 101 Expect.equals(#intField, pm.simpleName); |
95 Expect.equals(reflectClass(num), pm.type); | 102 Expect.equals(reflectClass(num), pm.type); |
96 Expect.isFalse(pm.isNamed); /// 01: ok | 103 Expect.isFalse(pm.isNamed); /// 01: ok |
97 Expect.isFalse(pm.isFinal); /// 01: ok | 104 Expect.isFalse(pm.isFinal); /// 01: ok |
98 Expect.isFalse(pm.isOptional); /// 01: ok | 105 Expect.isFalse(pm.isOptional); /// 01: ok |
99 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 106 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
100 Expect.isFalse(pm.isPrivate); | 107 Expect.isFalse(pm.isPrivate); |
101 Expect.isFalse(pm.isStatic); | 108 Expect.isFalse(pm.isStatic); |
102 Expect.isFalse(pm.isTopLevel); | 109 Expect.isFalse(pm.isTopLevel); |
103 | 110 |
104 pm = reflectClass(Class).constructors[#Class.withVar].parameters.single; | 111 mm = reflectClass(Class).declarations[#Class.withVar]; |
| 112 pm = mm.parameters.single; |
105 Expect.equals(#intField, pm.simpleName); | 113 Expect.equals(#intField, pm.simpleName); |
106 Expect.equals(reflectClass(int), pm.type); // N.B. /// 02: ok | 114 Expect.equals(reflectClass(int), pm.type); // N.B. /// 02: ok |
107 Expect.isFalse(pm.isNamed); /// 01: ok | 115 Expect.isFalse(pm.isNamed); /// 01: ok |
108 Expect.isFalse(pm.isFinal); /// 01: ok | 116 Expect.isFalse(pm.isFinal); /// 01: ok |
109 Expect.isFalse(pm.isOptional); /// 01: ok | 117 Expect.isFalse(pm.isOptional); /// 01: ok |
110 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 118 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
111 Expect.isFalse(pm.isPrivate); | 119 Expect.isFalse(pm.isPrivate); |
112 Expect.isFalse(pm.isStatic); | 120 Expect.isFalse(pm.isStatic); |
113 Expect.isFalse(pm.isTopLevel); | 121 Expect.isFalse(pm.isTopLevel); |
114 | 122 |
115 pm = reflectClass(Class).constructors[#Class.withDynamic].parameters.single; | 123 mm = reflectClass(Class).declarations[#Class.withDynamic]; |
| 124 pm = mm.parameters.single; |
116 Expect.equals(#intField, pm.simpleName); | 125 Expect.equals(#intField, pm.simpleName); |
117 Expect.equals(currentMirrorSystem().dynamicType, pm.type); // N.B. | 126 Expect.equals(currentMirrorSystem().dynamicType, pm.type); // N.B. |
118 Expect.isFalse(pm.isNamed); /// 01: ok | 127 Expect.isFalse(pm.isNamed); /// 01: ok |
119 Expect.isFalse(pm.isFinal); /// 01: ok | 128 Expect.isFalse(pm.isFinal); /// 01: ok |
120 Expect.isFalse(pm.isOptional); /// 01: ok | 129 Expect.isFalse(pm.isOptional); /// 01: ok |
121 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 130 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
122 Expect.isFalse(pm.isPrivate); | 131 Expect.isFalse(pm.isPrivate); |
123 Expect.isFalse(pm.isStatic); | 132 Expect.isFalse(pm.isStatic); |
124 Expect.isFalse(pm.isTopLevel); | 133 Expect.isFalse(pm.isTopLevel); |
125 | 134 |
126 pm = reflectClass(Constant).constructors[#Constant].parameters.single; | 135 mm = reflectClass(Constant).declarations[#Constant]; |
| 136 pm = mm.parameters.single; |
127 Expect.equals(#value, pm.simpleName); | 137 Expect.equals(#value, pm.simpleName); |
128 Expect.equals(reflectClass(num), pm.type); | 138 Expect.equals(reflectClass(num), pm.type); |
129 Expect.isFalse(pm.isNamed); /// 01: ok | 139 Expect.isFalse(pm.isNamed); /// 01: ok |
130 Expect.isFalse(pm.isFinal); // N.B. /// 01: ok | 140 Expect.isFalse(pm.isFinal); // N.B. /// 01: ok |
131 Expect.isFalse(pm.isOptional); /// 01: ok | 141 Expect.isFalse(pm.isOptional); /// 01: ok |
132 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 142 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
133 Expect.isFalse(pm.isPrivate); | 143 Expect.isFalse(pm.isPrivate); |
134 Expect.isFalse(pm.isStatic); | 144 Expect.isFalse(pm.isStatic); |
135 Expect.isFalse(pm.isTopLevel); | 145 Expect.isFalse(pm.isTopLevel); |
136 | 146 |
137 pm = reflectClass(Constant).constructors[#Constant.marked].parameters.single; | 147 mm = reflectClass(Constant).declarations[#Constant.marked]; |
| 148 pm = mm.parameters.single; |
138 Expect.equals(#value, pm.simpleName); | 149 Expect.equals(#value, pm.simpleName); |
139 Expect.equals(reflectClass(num), pm.type); | 150 Expect.equals(reflectClass(num), pm.type); |
140 Expect.isFalse(pm.isNamed); /// 01: ok | 151 Expect.isFalse(pm.isNamed); /// 01: ok |
141 Expect.isTrue(pm.isFinal); // N.B. /// 01: ok | 152 Expect.isTrue(pm.isFinal); // N.B. /// 01: ok |
142 Expect.isFalse(pm.isOptional); /// 01: ok | 153 Expect.isFalse(pm.isOptional); /// 01: ok |
143 Expect.isFalse(pm.hasDefaultValue); /// 01: ok | 154 Expect.isFalse(pm.hasDefaultValue); /// 01: ok |
144 Expect.isFalse(pm.isPrivate); | 155 Expect.isFalse(pm.isPrivate); |
145 Expect.isFalse(pm.isStatic); | 156 Expect.isFalse(pm.isStatic); |
146 Expect.isFalse(pm.isTopLevel); | 157 Expect.isFalse(pm.isTopLevel); |
147 } | 158 } |
OLD | NEW |