Chromium Code Reviews| Index: tests/lib/mirrors/generic_mixin_applications_test.dart |
| diff --git a/tests/lib/mirrors/generic_mixin_applications_test.dart b/tests/lib/mirrors/generic_mixin_applications_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ca053e2e6bbf280489ee4748c38cf8150bb748e6 |
| --- /dev/null |
| +++ b/tests/lib/mirrors/generic_mixin_applications_test.dart |
| @@ -0,0 +1,91 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.generic_mixin_applications; |
| + |
| +import 'dart:mirrors'; |
| + |
| +import 'package:expect/expect.dart'; |
| + |
| +import 'generics_test.dart'; |
| + |
| +class Super<S> {} |
| +class Mixin<M> {} |
| + |
| +typedef NonGenericMixinApplication1 = Super with Mixin; |
| +typedef NonGenericMixinApplication2 = Super<num> with Mixin<String>; |
| + |
| +typedef GenericMixinApplication1<MA> = Super<MA> with Mixin<MA>; |
| +typedef GenericMixinApplication2<MA> = Super<num> with Mixin<String>; |
| + |
| +class NonGenericClass1 extends Super with Mixin {} |
| +class NonGenericClass2 extends Super<num> with Mixin<String> {} |
| + |
| +class GenericClass1<C> extends Super<C> with Mixin<C> {} |
| +class GenericClass2<C> extends Super<num> with Mixin<String> {} |
| + |
| +main() { |
| + TypeMirror dynamicMirror = currentMirrorSystem().dynamicType; |
| + |
| + // Declarations. |
| + typeParameters(reflectClass(NonGenericMixinApplication1), []); |
| + typeParameters(reflectClass(NonGenericMixinApplication2), []); |
| + typeParameters(reflectClass(GenericMixinApplication1), [#MA]); |
| + typeParameters(reflectClass(GenericMixinApplication2), [#MA]); |
| + typeParameters(reflectClass(NonGenericClass1), []); |
| + typeParameters(reflectClass(NonGenericClass2), []); |
| + typeParameters(reflectClass(GenericClass1), [#C]); |
| + typeParameters(reflectClass(GenericClass2), [#C]); |
| + // The extact name of the type variable is not specified. |
|
gbracha
2013/10/02 20:57:14
extact -> exact
|
| + // Why 2? |
| + Expect.equals(2, reflectClass(NonGenericClass1).superclass.typeVariables.length); |
|
gbracha
2013/10/02 20:57:14
reflectClass(NonGenericClass1).superclass is a mir
|
| + Expect.equals(2, reflectClass(NonGenericClass2).superclass.typeVariables.length); |
|
gbracha
2013/10/02 20:57:14
Again, why type variables?
|
| + Expect.equals(2, reflectClass(GenericClass1).superclass.typeVariables.length); |
|
gbracha
2013/10/02 20:57:14
Ok. Here the superclass is Super<C> with Mixin<C>
|
| + Expect.equals(2, reflectClass(GenericClass2).superclass.typeVariables.length); |
| + |
| + typeArguments(reflectClass(NonGenericMixinApplication1), []); |
| + typeArguments(reflectClass(NonGenericMixinApplication2), []); |
| + typeArguments(reflectClass(GenericMixinApplication1), []); |
| + typeArguments(reflectClass(GenericMixinApplication2), []); |
| + typeArguments(reflectClass(NonGenericClass1), []); |
| + typeArguments(reflectClass(NonGenericClass2), []); |
| + typeArguments(reflectClass(GenericClass1), []); |
| + typeArguments(reflectClass(GenericClass2), []); |
| + typeArguments(reflectClass(NonGenericClass1).superclass.originalDeclaration, []); |
| + typeArguments(reflectClass(NonGenericClass2).superclass.originalDeclaration, []); |
| + typeArguments(reflectClass(GenericClass1).superclass.originalDeclaration, []); |
| + typeArguments(reflectClass(GenericClass2).superclass.originalDeclaration, []); |
| + |
| + |
| + // Instantiations. |
| + typeParameters(reflect(new NonGenericMixinApplication1()).type, []); |
| + typeParameters(reflect(new NonGenericMixinApplication2()).type, []); |
| + typeParameters(reflect(new GenericMixinApplication1<bool>()).type, [#MA]); |
| + typeParameters(reflect(new GenericMixinApplication2<bool>()).type, [#MA]); |
| + typeParameters(reflect(new NonGenericClass1()).type, []); |
| + typeParameters(reflect(new NonGenericClass2()).type, []); |
| + typeParameters(reflect(new GenericClass1<bool>()).type, [#C]); |
| + typeParameters(reflect(new GenericClass2<bool>()).type, [#C]); |
| + // The extact name of the type variable is not specified. |
|
gbracha
2013/10/02 20:57:14
extact -> exact
|
| + // Why 2? |
| + Expect.equals(2, reflect(new NonGenericClass1()).type.superclass.typeVariables.length); |
| + Expect.equals(2, reflect(new NonGenericClass2()).type.superclass.typeVariables.length); |
| + Expect.equals(2, reflect(new GenericClass1<bool>()).type.superclass.typeVariables.length); |
| + Expect.equals(2, reflect(new GenericClass2<bool>()).type.superclass.typeVariables.length); |
| + |
| + typeArguments(reflect(new NonGenericMixinApplication1()).type, []); |
| + typeArguments(reflect(new NonGenericMixinApplication2()).type, []); |
| + typeArguments(reflect(new GenericMixinApplication1<bool>()).type, [reflectClass(bool)]); |
| + typeArguments(reflect(new GenericMixinApplication2<bool>()).type, [reflectClass(bool)]); |
| + typeArguments(reflect(new NonGenericClass1()).type, []); |
| + typeArguments(reflect(new NonGenericClass2()).type, []); |
| + typeArguments(reflect(new GenericClass1<bool>()).type, [reflectClass(bool)]); |
| + typeArguments(reflect(new GenericClass2<bool>()).type, [reflectClass(bool)]); |
| + // Why 2? |
| + typeArguments(reflect(new NonGenericClass1()).type.superclass, [dynamicMirror, dynamicMirror]); |
| + typeArguments(reflect(new NonGenericClass2()).type.superclass, [reflectClass(num), reflectClass(String)]); |
| + // Hm? |
| + // typeArguments(reflect(new GenericClass1<bool>()).type.superclass, [dynamicMirror, dynamicMirror]); |
| + typeArguments(reflect(new GenericClass2<bool>()).type.superclass, [reflectClass(num), reflectClass(String)]); |
| +} |