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

Unified Diff: test/codegen/lib/mirrors/generic_superclass_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 side-by-side diff with in-line comments
Download patch
Index: test/codegen/lib/mirrors/generic_superclass_test.dart
diff --git a/test/codegen/lib/mirrors/generic_superclass_test.dart b/test/codegen/lib/mirrors/generic_superclass_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ebf4c8cf96b22f8f52474a23933b036a47aec6a7
--- /dev/null
+++ b/test/codegen/lib/mirrors/generic_superclass_test.dart
@@ -0,0 +1,120 @@
+// 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.
+
+import 'package:expect/expect.dart';
+import 'dart:mirrors';
+
+
+class A<T> {}
+class B extends A<U>{}
+class C extends A<C> {}
+class D<T> extends A<T> {}
+class E<X,Y> extends G<H<Y>> {}
+class F<X> implements A<X> {}
+class FF<X,Y> implements G<H<Y>> {}
+class G<T> {}
+class H<T> {}
+class U {}
+class R {}
+
+void testOriginals() {
+ ClassMirror a = reflectClass(A);
+ ClassMirror b = reflectClass(B);
+ ClassMirror c = reflectClass(C);
+ ClassMirror d = reflectClass(D);
+ ClassMirror e = reflectClass(E);
+ ClassMirror f = reflectClass(F);
+ ClassMirror ff = reflectClass(FF);
+ ClassMirror superA = a.superclass;
+ ClassMirror superB = b.superclass;
+ ClassMirror superC = c.superclass;
+ ClassMirror superD = d.superclass;
+ ClassMirror superE = e.superclass;
+ ClassMirror superInterfaceF = f.superinterfaces[0];
+ ClassMirror superInterfaceFF = ff.superinterfaces[0];
+
+ TypeVariableMirror aT = a.typeVariables[0];
+ TypeVariableMirror dT = d.typeVariables[0];
+ TypeVariableMirror eX = e.typeVariables[0];
+ TypeVariableMirror eY = e.typeVariables[1];
+ TypeVariableMirror fX = f.typeVariables[0];
+ TypeVariableMirror feX = ff.typeVariables[0];
+ TypeVariableMirror feY = ff.typeVariables[1];
+
+ Expect.isTrue(superA.isOriginalDeclaration);
+ Expect.isFalse(superB.isOriginalDeclaration);
+ Expect.isFalse(superC.isOriginalDeclaration);
+ Expect.isFalse(superD.isOriginalDeclaration);
+ Expect.isFalse(superE.isOriginalDeclaration);
+ Expect.isFalse(superInterfaceF.isOriginalDeclaration);
+ Expect.isFalse(superInterfaceFF.isOriginalDeclaration);
+
+ Expect.equals(reflectClass(Object), superA);
+ Expect.equals(reflect(new A<U>()).type, superB);
+ Expect.equals(reflect(new A<C>()).type, superC); /// 01: ok
+ Expect.equals(reflect(new U()).type, superB.typeArguments[0]);
+ Expect.equals(reflect(new C()).type, superC.typeArguments[0]); /// 01: ok
+ Expect.equals(dT, superD.typeArguments[0]);
+ Expect.equals(eY, superE.typeArguments[0].typeArguments[0]);
+ Expect.equals(feY, superInterfaceFF.typeArguments[0].typeArguments[0]);
+ Expect.equals(fX, superInterfaceF.typeArguments[0]);
+}
+
+void testInstances() {
+ ClassMirror a = reflect(new A<U>()).type;
+ ClassMirror b = reflect(new B()).type;
+ ClassMirror c = reflect(new C()).type;
+ ClassMirror d = reflect(new D<U>()).type;
+ ClassMirror e = reflect(new E<U,R>()).type;
+ ClassMirror e0 = reflect(new E<U,H<R>>()).type;
+ ClassMirror ff = reflect(new FF<U,R>()).type;
+ ClassMirror f = reflect(new F<U>()).type;
+ ClassMirror u = reflect(new U()).type;
+ ClassMirror r = reflect(new R()).type;
+ ClassMirror hr = reflect(new H<R>()).type;
+
+ ClassMirror superA = a.superclass;
+ ClassMirror superB = b.superclass;
+ ClassMirror superC = c.superclass;
+ ClassMirror superD = d.superclass;
+ ClassMirror superE = e.superclass;
+ ClassMirror superE0 = e0.superclass;
+ ClassMirror superInterfaceF = f.superinterfaces[0];
+ ClassMirror superInterfaceFF = ff.superinterfaces[0];
+
+ Expect.isTrue(superA.isOriginalDeclaration);
+ Expect.isFalse(superB.isOriginalDeclaration);
+ Expect.isFalse(superC.isOriginalDeclaration);
+ Expect.isFalse(superD.isOriginalDeclaration);
+ Expect.isFalse(superE.isOriginalDeclaration);
+ Expect.isFalse(superE0.isOriginalDeclaration);
+ Expect.isFalse(superInterfaceF.isOriginalDeclaration);
+ Expect.isFalse(superInterfaceFF.isOriginalDeclaration);
+
+ Expect.equals(reflectClass(Object), superA);
+ Expect.equals(reflect(new A<U>()).type, superB);
+ Expect.equals(reflect(new A<C>()).type, superC); /// 01: ok
+ Expect.equals(reflect(new A<U>()).type, superD);
+ Expect.equals(reflect(new G<H<R>>()).type, superE);
+ Expect.equals(reflect(new G<H<H<R>>>()).type, superE0);
+ Expect.equals(reflect(new G<H<R>>()).type, superInterfaceFF);
+ Expect.equals(u, superB.typeArguments[0]);
+ Expect.equals(reflect(new C()).type, superC.typeArguments[0]); /// 01: ok
+ Expect.equals(u, superD.typeArguments[0]);
+ Expect.equals(r, superE.typeArguments[0].typeArguments[0]);
+ Expect.equals(hr, superE0.typeArguments[0].typeArguments[0]);
+ Expect.equals(r, superInterfaceFF.typeArguments[0].typeArguments[0]);
+ Expect.equals(u, superInterfaceF.typeArguments[0]);
+}
+
+void testObject() {
+ ClassMirror object = reflectClass(Object);
+ Expect.equals(null, object.superclass);
+}
+
+main() {
+ testOriginals();
+ testInstances();
+ testObject();
+}
« no previous file with comments | « test/codegen/lib/mirrors/generic_mixin_test.dart ('k') | test/codegen/lib/mirrors/generic_type_mirror_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698