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 // This tests uses the multi-test "ok" feature: | 5 // This tests uses the multi-test "ok" feature: |
6 // none: Desired behaviour, passing on the VM. | 6 // none: Desired behaviour, passing on the VM. |
7 // 01: Trimmed version for dart2js. | 7 // 01: Trimmed version for dart2js. |
8 // | 8 // |
9 // TODO(rmacnak,ahe): Remove multi-test when VM and dart2js are on par. | 9 // TODO(rmacnak,ahe): Remove multi-test when VM and dart2js are on par. |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 class C <S extends int, T> { | 40 class C <S extends int, T> { |
41 // TODO(6490): Currently only supported by the VM. | 41 // TODO(6490): Currently only supported by the VM. |
42 foo(int a, S b) => b; | 42 foo(int a, S b) => b; |
43 bar(S a, T b, num c) {} | 43 bar(S a, T b, num c) {} |
44 } | 44 } |
45 | 45 |
46 main() { | 46 main() { |
47 ClassMirror cm = reflectClass(B); | 47 ClassMirror cm = reflectClass(B); |
48 Map<Symbol, MethodMirror> constructors = cm.constructors; | 48 var constructors = new Map<Symbol, MethodMirror>(); |
| 49 cm.declarations.forEach((k, v) { |
| 50 if (v is MethodMirror && v.isConstructor) constructors[k] = v; |
| 51 }); |
49 | 52 |
50 List<Symbol> constructorKeys = | 53 List<Symbol> constructorKeys = |
51 [#B, #B.bar, #B.baz, #B.foo, #B.quux, #B.qux, #B.corge]; | 54 [#B, #B.bar, #B.baz, #B.foo, #B.quux, #B.qux, #B.corge]; |
52 Expect.setEquals(constructorKeys, constructors.keys); | 55 Expect.setEquals(constructorKeys, constructors.keys); |
53 | 56 |
54 MethodMirror unnamedConstructor = constructors[#B]; | 57 MethodMirror unnamedConstructor = constructors[#B]; |
55 expect('Method(s(B) in s(B), constructor)', unnamedConstructor); | 58 expect('Method(s(B) in s(B), constructor)', unnamedConstructor); |
56 expect('[]', unnamedConstructor.parameters); | 59 expect('[]', unnamedConstructor.parameters); |
57 expect('Class(s(B) in s(test.parameter_test), top-level)', | 60 expect('Class(s(B) in s(test.parameter_test), top-level)', |
58 unnamedConstructor.returnType); | 61 unnamedConstructor.returnType); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 expect('[Parameter(s(x) in s(B.corge), optional, named,' | 120 expect('[Parameter(s(x) in s(B.corge), optional, named,' |
118 ' value = Instance(value = 51),' | 121 ' value = Instance(value = 51),' |
119 ' type = Class(s(int) in s(dart.core), top-level)), ' | 122 ' type = Class(s(int) in s(dart.core), top-level)), ' |
120 'Parameter(s(str) in s(B.corge), optional, named,' | 123 'Parameter(s(str) in s(B.corge), optional, named,' |
121 ' value = Instance(value = bar),' | 124 ' value = Instance(value = bar),' |
122 ' type = Class(s(String) in s(dart.core), top-level))]', | 125 ' type = Class(s(String) in s(dart.core), top-level))]', |
123 corgeConstructor.parameters); | 126 corgeConstructor.parameters); |
124 expect('Class(s(B) in s(test.parameter_test), top-level)', | 127 expect('Class(s(B) in s(test.parameter_test), top-level)', |
125 corgeConstructor.returnType); | 128 corgeConstructor.returnType); |
126 | 129 |
127 MethodMirror xGetter = cm.getters[#x]; | 130 MethodMirror xGetter = cm.declarations[#x]; |
128 expect('Method(s(x) in s(B), getter)', xGetter); | 131 expect('Method(s(x) in s(B), getter)', xGetter); |
129 expect('[]', xGetter.parameters); | 132 expect('[]', xGetter.parameters); |
130 | 133 |
131 MethodMirror xSetter = cm.setters[const Symbol('x=')]; | 134 MethodMirror xSetter = cm.declarations[const Symbol('x=')]; |
132 expect('Method(s(x=) in s(B), setter)', xSetter); | 135 expect('Method(s(x=) in s(B), setter)', xSetter); |
133 expect('[Parameter(s(value) in s(x=), final,' | 136 expect('[Parameter(s(value) in s(x=), final,' |
134 ' type = Type(s(dynamic), top-level))]', | 137 ' type = Type(s(dynamic), top-level))]', |
135 xSetter.parameters); | 138 xSetter.parameters); |
136 | 139 |
137 MethodMirror grault = cm.members[#grault]; | 140 MethodMirror grault = cm.declarations[#grault]; |
138 expect('Method(s(grault) in s(B))', grault); | 141 expect('Method(s(grault) in s(B))', grault); |
139 expect('[Parameter(s(x) in s(grault), optional,' | 142 expect('[Parameter(s(x) in s(grault), optional,' |
140 ' type = Class(s(int) in s(dart.core), top-level))]', | 143 ' type = Class(s(int) in s(dart.core), top-level))]', |
141 grault.parameters); | 144 grault.parameters); |
142 expect('Instance(value = <null>)', grault.parameters[0].defaultValue); | 145 expect('Instance(value = <null>)', grault.parameters[0].defaultValue); |
143 | 146 |
144 MethodMirror garply = cm.members[#garply]; | 147 MethodMirror garply = cm.declarations[#garply]; |
145 expect('Method(s(garply) in s(B))', garply); | 148 expect('Method(s(garply) in s(B))', garply); |
146 expect('[Parameter(s(y) in s(garply), optional, named,' | 149 expect('[Parameter(s(y) in s(garply), optional, named,' |
147 ' type = Class(s(int) in s(dart.core), top-level))]', | 150 ' type = Class(s(int) in s(dart.core), top-level))]', |
148 garply.parameters); | 151 garply.parameters); |
149 expect('Instance(value = <null>)', garply.parameters[0].defaultValue); | 152 expect('Instance(value = <null>)', garply.parameters[0].defaultValue); |
150 | 153 |
151 MethodMirror waldo = cm.members[#waldo]; | 154 MethodMirror waldo = cm.declarations[#waldo]; |
152 expect('Method(s(waldo) in s(B))', waldo); | 155 expect('Method(s(waldo) in s(B))', waldo); |
153 expect('[Parameter(s(z) in s(waldo),' | 156 expect('[Parameter(s(z) in s(waldo),' |
154 ' type = Class(s(int) in s(dart.core), top-level))]', | 157 ' type = Class(s(int) in s(dart.core), top-level))]', |
155 waldo.parameters); | 158 waldo.parameters); |
156 expect('<null>', waldo.parameters[0].defaultValue); | 159 expect('<null>', waldo.parameters[0].defaultValue); |
157 | 160 |
158 cm = reflectClass(C); | 161 cm = reflectClass(C); |
159 | 162 |
160 MethodMirror fooInC = cm.members[#foo]; | 163 MethodMirror fooInC = cm.declarations[#foo]; |
161 expect('Method(s(foo) in s(C))', fooInC); | 164 expect('Method(s(foo) in s(C))', fooInC); |
162 expect('[Parameter(s(a) in s(foo),' | 165 expect('[Parameter(s(a) in s(foo),' |
163 ' type = Class(s(int) in s(dart.core), top-level)), ' | 166 ' type = Class(s(int) in s(dart.core), top-level)), ' |
164 'Parameter(s(b) in s(foo),' | 167 'Parameter(s(b) in s(foo),' |
165 ' type = TypeVariable(s(S) in s(C),' | 168 ' type = TypeVariable(s(S) in s(C),' |
166 ' upperBound = Class(s(int) in s(dart.core), top-level)))]', | 169 ' upperBound = Class(s(int) in s(dart.core), top-level)))]', |
167 fooInC.parameters); | 170 fooInC.parameters); |
168 | 171 |
169 MethodMirror barInC = cm.members[#bar]; | 172 MethodMirror barInC = cm.declarations[#bar]; |
170 expect('Method(s(bar) in s(C))', barInC); | 173 expect('Method(s(bar) in s(C))', barInC); |
171 expect('[Parameter(s(a) in s(bar),' | 174 expect('[Parameter(s(a) in s(bar),' |
172 ' type = TypeVariable(s(S) in s(C),' | 175 ' type = TypeVariable(s(S) in s(C),' |
173 ' upperBound = Class(s(int) in s(dart.core), top-level))), ' | 176 ' upperBound = Class(s(int) in s(dart.core), top-level))), ' |
174 'Parameter(s(b) in s(bar),' | 177 'Parameter(s(b) in s(bar),' |
175 ' type = TypeVariable(s(T) in s(C),' | 178 ' type = TypeVariable(s(T) in s(C),' |
176 ' upperBound = Class(s(Object) in s(dart.core), top-level))), ' | 179 ' upperBound = Class(s(Object) in s(dart.core), top-level))), ' |
177 'Parameter(s(c) in s(bar),' | 180 'Parameter(s(c) in s(bar),' |
178 ' type = Class(s(num) in s(dart.core), top-level))]', | 181 ' type = Class(s(num) in s(dart.core), top-level))]', |
179 barInC.parameters); | 182 barInC.parameters); |
180 } | 183 } |
OLD | NEW |