Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: tests/lib/mirrors/generic_mixin_applications_test.dart

Issue 25609003: Add missing test coverage for constructor kinds, generic function typedefs and generic mixin applic… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: delegate test Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.generic_mixin_applications;
6
7 import 'dart:mirrors';
8
9 import 'package:expect/expect.dart';
10
11 import 'generics_test.dart';
12
13 class Super<S> {}
14 class Mixin<M> {}
15
16 typedef NonGenericMixinApplication1 = Super with Mixin;
17 typedef NonGenericMixinApplication2 = Super<num> with Mixin<String>;
18
19 typedef GenericMixinApplication1<MA> = Super<MA> with Mixin<MA>;
20 typedef GenericMixinApplication2<MA> = Super<num> with Mixin<String>;
21
22 class NonGenericClass1 extends Super with Mixin {}
23 class NonGenericClass2 extends Super<num> with Mixin<String> {}
24
25 class GenericClass1<C> extends Super<C> with Mixin<C> {}
26 class GenericClass2<C> extends Super<num> with Mixin<String> {}
27
28 main() {
29 TypeMirror dynamicMirror = currentMirrorSystem().dynamicType;
30
31 // Declarations.
32 typeParameters(reflectClass(NonGenericMixinApplication1), []);
33 typeParameters(reflectClass(NonGenericMixinApplication2), []);
34 typeParameters(reflectClass(GenericMixinApplication1), [#MA]);
35 typeParameters(reflectClass(GenericMixinApplication2), [#MA]);
36 typeParameters(reflectClass(NonGenericClass1), []);
37 typeParameters(reflectClass(NonGenericClass2), []);
38 typeParameters(reflectClass(GenericClass1), [#C]);
39 typeParameters(reflectClass(GenericClass2), [#C]);
40 // The extact name of the type variable is not specified.
41 // Why 2?
gbracha 2013/10/02 21:20:39 So the 2 is the VM's implementation leaking inform
42 Expect.equals(2, reflectClass(NonGenericClass1).superclass.typeVariables.lengt h);
43 Expect.equals(2, reflectClass(NonGenericClass2).superclass.typeVariables.lengt h);
44 Expect.equals(2, reflectClass(GenericClass1).superclass.typeVariables.length);
45 Expect.equals(2, reflectClass(GenericClass2).superclass.typeVariables.length);
46
47 typeArguments(reflectClass(NonGenericMixinApplication1), []);
48 typeArguments(reflectClass(NonGenericMixinApplication2), []);
49 typeArguments(reflectClass(GenericMixinApplication1), []);
50 typeArguments(reflectClass(GenericMixinApplication2), []);
51 typeArguments(reflectClass(NonGenericClass1), []);
52 typeArguments(reflectClass(NonGenericClass2), []);
53 typeArguments(reflectClass(GenericClass1), []);
54 typeArguments(reflectClass(GenericClass2), []);
55 typeArguments(reflectClass(NonGenericClass1).superclass.originalDeclaration, [ ]);
56 typeArguments(reflectClass(NonGenericClass2).superclass.originalDeclaration, [ ]);
57 typeArguments(reflectClass(GenericClass1).superclass.originalDeclaration, []);
58 typeArguments(reflectClass(GenericClass2).superclass.originalDeclaration, []);
59
60
61 // Instantiations.
62 typeParameters(reflect(new NonGenericMixinApplication1()).type, []);
63 typeParameters(reflect(new NonGenericMixinApplication2()).type, []);
64 typeParameters(reflect(new GenericMixinApplication1<bool>()).type, [#MA]);
65 typeParameters(reflect(new GenericMixinApplication2<bool>()).type, [#MA]);
66 typeParameters(reflect(new NonGenericClass1()).type, []);
67 typeParameters(reflect(new NonGenericClass2()).type, []);
68 typeParameters(reflect(new GenericClass1<bool>()).type, [#C]);
69 typeParameters(reflect(new GenericClass2<bool>()).type, [#C]);
70 // The extact name of the type variable is not specified.
71 // Why 2?
72 Expect.equals(2, reflect(new NonGenericClass1()).type.superclass.typeVariables .length);
73 Expect.equals(2, reflect(new NonGenericClass2()).type.superclass.typeVariables .length);
74 Expect.equals(2, reflect(new GenericClass1<bool>()).type.superclass.typeVariab les.length);
75 Expect.equals(2, reflect(new GenericClass2<bool>()).type.superclass.typeVariab les.length);
76
77 typeArguments(reflect(new NonGenericMixinApplication1()).type, []);
78 typeArguments(reflect(new NonGenericMixinApplication2()).type, []);
79 typeArguments(reflect(new GenericMixinApplication1<bool>()).type, [reflectClas s(bool)]);
80 typeArguments(reflect(new GenericMixinApplication2<bool>()).type, [reflectClas s(bool)]);
81 typeArguments(reflect(new NonGenericClass1()).type, []);
82 typeArguments(reflect(new NonGenericClass2()).type, []);
83 typeArguments(reflect(new GenericClass1<bool>()).type, [reflectClass(bool)]);
84 typeArguments(reflect(new GenericClass2<bool>()).type, [reflectClass(bool)]);
85 // Why 2?
86 typeArguments(reflect(new NonGenericClass1()).type.superclass, [dynamicMirror, dynamicMirror]);
87 typeArguments(reflect(new NonGenericClass2()).type.superclass, [reflectClass(n um), reflectClass(String)]);
88 // Hm?
89 // typeArguments(reflect(new GenericClass1<bool>()).type.superclass, [dynamicM irror, dynamicMirror]);
90 typeArguments(reflect(new GenericClass2<bool>()).type.superclass, [reflectClas s(num), reflectClass(String)]);
91 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/generic_function_typedef_test.dart ('k') | tests/lib/mirrors/generics_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698