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