OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library test.parameter_of_mixin_app_constructor; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 import 'stringify.dart'; |
| 9 |
| 10 class MapView { |
| 11 final _map; |
| 12 MapView(map) : this._map = map; |
| 13 } |
| 14 |
| 15 abstract class UnmodifiableMapMixin { |
| 16 someFunctionality() {} |
| 17 } |
| 18 |
| 19 class UnmodifiableMapView1 extends MapView with UnmodifiableMapMixin { |
| 20 UnmodifiableMapView1(map1) : super(map1); |
| 21 } |
| 22 |
| 23 class UnmodifiableMapView2 = MapView with UnmodifiableMapMixin; |
| 24 |
| 25 class S { |
| 26 S(int p1, String p2); |
| 27 } |
| 28 |
| 29 class M1 { } |
| 30 class M2 { } |
| 31 class M3 { } |
| 32 |
| 33 class MorePlumbing = S with M1, M2, M3; |
| 34 |
| 35 soleConstructorOf(ClassMirror cm) { |
| 36 return cm.declarations.values |
| 37 .where((dm) => dm is MethodMirror && dm.isConstructor).single; |
| 38 } |
| 39 |
| 40 main() { |
| 41 ClassMirror umv1 = reflectClass(UnmodifiableMapView1); |
| 42 expect('[Parameter(s(map1) in s(UnmodifiableMapView1),' |
| 43 ' type = Type(s(dynamic), top-level))]', |
| 44 soleConstructorOf(umv1).parameters); |
| 45 expect('[Parameter(s(map) in s(test.parameter_of_mixin_app_constructor.MapView
' |
| 46 ' with test.parameter_of_mixin_app_constructor.UnmodifiableMapMixin),' |
| 47 ' type = Type(s(dynamic), top-level))]', |
| 48 soleConstructorOf(umv1.superclass).parameters); |
| 49 expect('[Parameter(s(map) in s(MapView),' |
| 50 ' type = Type(s(dynamic), top-level))]', |
| 51 soleConstructorOf(umv1.superclass.superclass).parameters); |
| 52 expect('[]', |
| 53 soleConstructorOf(umv1.superclass.superclass.superclass).parameters); |
| 54 |
| 55 ClassMirror umv2 = reflectClass(UnmodifiableMapView2); |
| 56 expect('[Parameter(s(map) in s(UnmodifiableMapView2),' |
| 57 ' type = Type(s(dynamic), top-level))]', |
| 58 soleConstructorOf(umv2).parameters); |
| 59 expect('[Parameter(s(map) in s(MapView),' |
| 60 ' type = Type(s(dynamic), top-level))]', |
| 61 soleConstructorOf(umv2.superclass).parameters); |
| 62 expect('[]', |
| 63 soleConstructorOf(umv2.superclass.superclass).parameters); |
| 64 |
| 65 ClassMirror mp = reflectClass(MorePlumbing); |
| 66 expect('[Parameter(s(p1) in s(MorePlumbing),' |
| 67 ' type = Class(s(int) in s(dart.core), top-level)),' |
| 68 ' Parameter(s(p2) in s(MorePlumbing),' |
| 69 ' type = Class(s(String) in s(dart.core), top-level))]', |
| 70 soleConstructorOf(mp).parameters); |
| 71 expect('[Parameter(s(p1) in s(test.parameter_of_mixin_app_constructor.S' |
| 72 ' with test.parameter_of_mixin_app_constructor.M1,' |
| 73 ' test.parameter_of_mixin_app_constructor.M2),' |
| 74 ' type = Class(s(int) in s(dart.core), top-level)),' |
| 75 ' Parameter(s(p2) in s(test.parameter_of_mixin_app_constructor.S' |
| 76 ' with test.parameter_of_mixin_app_constructor.M1,' |
| 77 ' test.parameter_of_mixin_app_constructor.M2),' |
| 78 ' type = Class(s(String) in s(dart.core), top-level))]', |
| 79 soleConstructorOf(mp.superclass).parameters); |
| 80 expect('[Parameter(s(p1) in s(test.parameter_of_mixin_app_constructor.S' |
| 81 ' with test.parameter_of_mixin_app_constructor.M1),' |
| 82 ' type = Class(s(int) in s(dart.core), top-level)),' |
| 83 ' Parameter(s(p2) in s(test.parameter_of_mixin_app_constructor.S' |
| 84 ' with test.parameter_of_mixin_app_constructor.M1),' |
| 85 ' type = Class(s(String) in s(dart.core), top-level))]', |
| 86 soleConstructorOf(mp.superclass.superclass).parameters); |
| 87 expect('[Parameter(s(p1) in s(S),' |
| 88 ' type = Class(s(int) in s(dart.core), top-level)),' |
| 89 ' Parameter(s(p2) in s(S),' |
| 90 ' type = Class(s(String) in s(dart.core), top-level))]', |
| 91 soleConstructorOf(mp.superclass.superclass.superclass).parameters); |
| 92 expect('[]', |
| 93 soleConstructorOf(mp.superclass.superclass.superclass.superclass).param
eters); |
| 94 } |
OLD | NEW |