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

Side by Side Diff: test/codegen/lib/mirrors/generics_dynamic_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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
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 import 'dart:mirrors';
6 import 'package:expect/expect.dart';
7
8 class A<T> {}
9 class B<T extends A> extends A implements C{
10 A m(A a) {}
11 A field;
12 }
13 class C<S,T> {}
14 class D extends A<int> {}
15
16 main() {
17 ClassMirror aDecl = reflectClass(A);
18 ClassMirror bDecl = reflectClass(B);
19 ClassMirror cDecl = reflectClass(C);
20 TypeMirror aInstance = reflect(new A()).type;
21 TypeMirror aInstanceDynamic = reflect(new A<dynamic>()).type;
22 TypeMirror dInstance = reflect(new D()).type;
23 TypeMirror cInstance = reflect(new C<dynamic, dynamic>()).type;
24 TypeMirror cNestedInstance = reflect(new C<C, dynamic>()).type;
25 TypeMirror cTypeArgument = cNestedInstance.typeArguments.first;
26 TypeMirror superA = bDecl.superclass;
27 TypeMirror superC = bDecl.superinterfaces.single;
28 MethodMirror m = bDecl.declarations[#m];
29 VariableMirror field = bDecl.declarations[#field];
30 TypeMirror returnTypeA = m.returnType;
31 TypeMirror parameterTypeA = m.parameters.first.type;
32 TypeMirror fieldTypeA = field.type;
33 TypeMirror upperBoundA = bDecl.typeVariables.single.upperBound;
34 TypeMirror dynamicMirror = currentMirrorSystem().dynamicType;
35
36 Expect.isTrue(aDecl.isOriginalDeclaration);
37 Expect.isTrue(reflect(dInstance).type.isOriginalDeclaration);
38 Expect.isFalse(aInstance.isOriginalDeclaration);
39 Expect.isFalse(aInstanceDynamic.isOriginalDeclaration);
40 Expect.isFalse(superA.isOriginalDeclaration);
41 Expect.isFalse(superC.isOriginalDeclaration);
42 Expect.isFalse(returnTypeA.isOriginalDeclaration);
43 Expect.isFalse(parameterTypeA.isOriginalDeclaration);
44 Expect.isFalse(fieldTypeA.isOriginalDeclaration);
45 Expect.isFalse(upperBoundA.isOriginalDeclaration);
46 Expect.isFalse(cInstance.isOriginalDeclaration);
47 Expect.isFalse(cNestedInstance.isOriginalDeclaration);
48 Expect.isFalse(cTypeArgument.isOriginalDeclaration);
49
50 Expect.isTrue(aDecl.typeArguments.isEmpty);
51 Expect.isTrue(dInstance.typeArguments.isEmpty);
52 Expect.equals(dynamicMirror, aInstance.typeArguments.single);
53 Expect.equals(dynamicMirror, aInstanceDynamic.typeArguments.single);
54 Expect.equals(dynamicMirror, superA.typeArguments.single);
55 Expect.equals(dynamicMirror, superC.typeArguments.first);
56 Expect.equals(dynamicMirror, superC.typeArguments.last);
57 Expect.equals(dynamicMirror, returnTypeA.typeArguments.single);
58 Expect.equals(dynamicMirror, parameterTypeA.typeArguments.single);
59 Expect.equals(dynamicMirror, fieldTypeA.typeArguments.single);
60 Expect.equals(dynamicMirror, upperBoundA.typeArguments.single);
61 Expect.equals(dynamicMirror, cInstance.typeArguments.first);
62 Expect.equals(dynamicMirror, cInstance.typeArguments.last);
63 Expect.equals(dynamicMirror, cNestedInstance.typeArguments.last);
64 Expect.equals(dynamicMirror, cTypeArgument.typeArguments.first);
65 Expect.equals(dynamicMirror, cTypeArgument.typeArguments.last);
66 }
OLDNEW
« no previous file with comments | « test/codegen/lib/mirrors/generics_double_substitution_test.dart ('k') | test/codegen/lib/mirrors/generics_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698