| 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 /// Test of [ParameterMirror]. | 5 /// Test of [ParameterMirror]. |
| 6 library test.parameter_test; | 6 library test.parameter_test; |
| 7 | 7 |
| 8 @MirrorsUsed(targets: 'test.parameter_test', override: '*') | 8 @MirrorsUsed(targets: 'test.parameter_test', override: '*') |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 var _x; | 25 var _x; |
| 26 get x => _x; | 26 get x => _x; |
| 27 set x(final value) { _x = value; } | 27 set x(final value) { _x = value; } |
| 28 | 28 |
| 29 grault([int x]); | 29 grault([int x]); |
| 30 garply({int y}); | 30 garply({int y}); |
| 31 waldo(int z); | 31 waldo(int z); |
| 32 } | 32 } |
| 33 | 33 |
| 34 class C <S extends int, T> { |
| 35 // TODO(6490): Currently only supported by the VM. |
| 36 foo(int a, S b) => b; |
| 37 bar(S a, T b, num c) {} |
| 38 } |
| 39 |
| 34 main() { | 40 main() { |
| 35 ClassMirror cm = reflectClass(B); | 41 ClassMirror cm = reflectClass(B); |
| 36 Map<Symbol, MethodMirror> constructors = cm.constructors; | 42 Map<Symbol, MethodMirror> constructors = cm.constructors; |
| 37 | 43 |
| 38 List<Symbol> constructorKeys = [ | 44 List<Symbol> constructorKeys = [ |
| 39 const Symbol('B'), const Symbol('B.bar'), const Symbol('B.baz'), | 45 const Symbol('B'), const Symbol('B.bar'), const Symbol('B.baz'), |
| 40 const Symbol('B.foo'), const Symbol('B.quux'), const Symbol('B.qux'), | 46 const Symbol('B.foo'), const Symbol('B.quux'), const Symbol('B.qux'), |
| 41 const Symbol('B.corge')]; | 47 const Symbol('B.corge')]; |
| 42 Expect.setEquals(constructorKeys, constructors.keys); | 48 Expect.setEquals(constructorKeys, constructors.keys); |
| 43 | 49 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ' type = Class(s(int) in s(dart.core), top-level))]', | 140 ' type = Class(s(int) in s(dart.core), top-level))]', |
| 135 garply.parameters); | 141 garply.parameters); |
| 136 expect('Instance(value = <null>)', garply.parameters[0].defaultValue); | 142 expect('Instance(value = <null>)', garply.parameters[0].defaultValue); |
| 137 | 143 |
| 138 MethodMirror waldo = cm.members[const Symbol("waldo")]; | 144 MethodMirror waldo = cm.members[const Symbol("waldo")]; |
| 139 expect('Method(s(waldo) in s(B))', waldo); | 145 expect('Method(s(waldo) in s(B))', waldo); |
| 140 expect('[Parameter(s(z) in s(waldo),' | 146 expect('[Parameter(s(z) in s(waldo),' |
| 141 ' type = Class(s(int) in s(dart.core), top-level))]', | 147 ' type = Class(s(int) in s(dart.core), top-level))]', |
| 142 waldo.parameters); | 148 waldo.parameters); |
| 143 expect('<null>', waldo.parameters[0].defaultValue); | 149 expect('<null>', waldo.parameters[0].defaultValue); |
| 150 |
| 151 cm = reflectClass(C); |
| 152 |
| 153 MethodMirror fooInC = cm.members[const Symbol("foo")]; |
| 154 expect('Method(s(foo) in s(C))', fooInC); |
| 155 expect('[Parameter(s(a) in s(foo),' |
| 156 ' type = Class(s(int) in s(dart.core), top-level)), ' |
| 157 'Parameter(s(b) in s(foo),' |
| 158 ' type = TypeVariable(s(S) in s(C),' |
| 159 ' upperBound = Class(s(int) in s(dart.core), top-level)))]', |
| 160 fooInC.parameters); |
| 161 |
| 162 MethodMirror barInC = cm.members[const Symbol("bar")]; |
| 163 expect('Method(s(bar) in s(C))', barInC); |
| 164 expect('[Parameter(s(a) in s(bar),' |
| 165 ' type = TypeVariable(s(S) in s(C),' |
| 166 ' upperBound = Class(s(int) in s(dart.core), top-level))), ' |
| 167 'Parameter(s(b) in s(bar),' |
| 168 ' type = TypeVariable(s(T) in s(C),' |
| 169 ' upperBound = Class(s(Object) in s(dart.core), top-level))), ' |
| 170 'Parameter(s(c) in s(bar),' |
| 171 ' type = Class(s(num) in s(dart.core), top-level))]', |
| 172 barInC.parameters); |
| 144 } | 173 } |
| OLD | NEW |