| 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 |
| 11 import 'stringify.dart'; | 11 import 'stringify.dart'; |
| 12 | 12 |
| 13 class B { | 13 class B { |
| 14 B(); | 14 B(); |
| 15 B.foo(int x); | 15 B.foo(int x); |
| 16 B.bar(int z, x); | 16 B.bar(int z, x); |
| 17 } | 17 } |
| 18 | 18 |
| 19 main() { | 19 main() { |
| 20 var constructors = reflectClass(B).constructors; | 20 var constructors = reflectClass(B).constructors; |
| 21 | 21 |
| 22 expect('{B: Method(s(B) in s(B), constructor), ' | 22 expect('{B: Method(s(B) in s(B), constructor), ' |
| 23 'B.bar: Method(s(B.bar) in s(B), constructor), ' | 23 'B.bar: Method(s(B.bar) in s(B), constructor), ' |
| 24 'B.foo: Method(s(B.foo) in s(B), constructor)}', | 24 'B.foo: Method(s(B.foo) in s(B), constructor)}', |
| 25 constructors); | 25 constructors); |
| 26 | 26 |
| 27 var unnamedConstructor = constructors[new Symbol('B')]; | 27 var unnamedConstructor = constructors[new Symbol('B')]; |
| 28 | 28 |
| 29 expect('[]', unnamedConstructor.parameters); | 29 expect('[]', unnamedConstructor.parameters); |
| 30 expect('Type(s(B) in s(test.parameter_test), top-level)', | 30 expect('Class(s(B) in s(test.parameter_test), top-level)', |
| 31 unnamedConstructor.returnType); | 31 unnamedConstructor.returnType); |
| 32 | 32 |
| 33 var fooConstructor = constructors[new Symbol('B.foo')]; | 33 var fooConstructor = constructors[new Symbol('B.foo')]; |
| 34 expect('[Parameter(s(x) in s(B.foo),' | 34 expect('[Parameter(s(x) in s(B.foo),' |
| 35 ' type = Type(s(int) in s(dart.core), top-level))]', | 35 ' type = Class(s(int) in s(dart.core), top-level))]', |
| 36 fooConstructor.parameters); | 36 fooConstructor.parameters); |
| 37 expect('Type(s(B) in s(test.parameter_test), top-level)', | 37 expect('Class(s(B) in s(test.parameter_test), top-level)', |
| 38 fooConstructor.returnType); | 38 fooConstructor.returnType); |
| 39 | 39 |
| 40 var barConstructor = constructors[new Symbol('B.bar')]; | 40 var barConstructor = constructors[new Symbol('B.bar')]; |
| 41 expect('[Parameter(s(z) in s(B.bar),' | 41 expect('[Parameter(s(z) in s(B.bar),' |
| 42 ' type = Type(s(int) in s(dart.core), top-level)), ' | 42 ' type = Class(s(int) in s(dart.core), top-level)), ' |
| 43 'Parameter(s(x) in s(B.bar),' | 43 'Parameter(s(x) in s(B.bar),' |
| 44 ' type = Type(s(dynamic), top-level))]', | 44 ' type = Type(s(dynamic), top-level))]', |
| 45 barConstructor.parameters); | 45 barConstructor.parameters); |
| 46 expect('Type(s(B) in s(test.parameter_test), top-level)', | 46 expect('Class(s(B) in s(test.parameter_test), top-level)', |
| 47 barConstructor.returnType); | 47 barConstructor.returnType); |
| 48 | 48 |
| 49 print(constructors); | 49 print(constructors); |
| 50 } | 50 } |
| OLD | NEW |