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

Unified Diff: tests/lib/mirrors/class_mirror_type_variables_test.dart

Issue 108753003: Test source mirrors with lib/mirrors test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment. Created 6 years, 10 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
« no previous file with comments | « tests/lib/mirrors/class_mirror_type_variables_expect.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/class_mirror_type_variables_test.dart
diff --git a/tests/lib/mirrors/class_mirror_type_variables_test.dart b/tests/lib/mirrors/class_mirror_type_variables_test.dart
index 51da82ec6618fa024d118660a0182c4322f57baf..8918de7bbbd4d14ef0e5a197b2cadd8dabc4b8a9 100644
--- a/tests/lib/mirrors/class_mirror_type_variables_test.dart
+++ b/tests/lib/mirrors/class_mirror_type_variables_test.dart
@@ -6,120 +6,22 @@ import "dart:mirrors";
import "package:expect/expect.dart";
-class NoTypeParams {}
-class A<T, S extends String> {}
-class B<Z extends B<Z>> {}
-class C<Z extends B<Z>> {}
-class D<R,S,T> {
- R foo(R r) => r;
- S bar(S s) => s;
- T baz(T t) => t;
-}
-class Helper<S> {}
-class E<R extends Map<R, Helper<String>>> {}
-class F<Z extends Helper<F<Z>>> {}
-
-testNoTypeParams() {
- ClassMirror cm = reflectClass(NoTypeParams);
- Expect.equals(cm.typeVariables.length, 0);
-}
-
-void testA() {
- ClassMirror a = reflectClass(A);
- Expect.equals(2, a.typeVariables.length);
-
- TypeVariableMirror aT = a.typeVariables[0];
- TypeVariableMirror aS = a.typeVariables[1];
- ClassMirror aTBound = aT.upperBound;
- ClassMirror aSBound = aS.upperBound;
-
- Expect.isTrue(aTBound.isOriginalDeclaration);
- Expect.isTrue(aSBound.isOriginalDeclaration);
-
- Expect.equals(reflectClass(Object), aTBound);
- Expect.equals(reflectClass(String), aSBound);
-}
-
-void testBAndC() {
- ClassMirror b = reflectClass(B);
- ClassMirror c = reflectClass(C);
-
- Expect.equals(1, b.typeVariables.length);
- Expect.equals(1, c.typeVariables.length);
-
- TypeVariableMirror bZ = b.typeVariables[0];
- TypeVariableMirror cZ = c.typeVariables[0];
- ClassMirror bZBound = bZ.upperBound;
- ClassMirror cZBound = cZ.upperBound;
-
- Expect.isFalse(bZBound.isOriginalDeclaration);
- Expect.isFalse(cZBound.isOriginalDeclaration);
-
- Expect.notEquals(bZBound, cZBound);
- Expect.equals(b, bZBound.originalDeclaration);
- Expect.equals(b, cZBound.originalDeclaration);
-
- TypeMirror bZBoundTypeArgument = bZBound.typeArguments.single;
- TypeMirror cZBoundTypeArgument = cZBound.typeArguments.single;
- TypeVariableMirror bZBoundTypeVariable = bZBound.typeVariables.single;
- TypeVariableMirror cZBoundTypeVariable = cZBound.typeVariables.single;
-
- Expect.equals(b, bZ.owner);
- Expect.equals(c, cZ.owner);
- Expect.equals(b, bZBoundTypeVariable.owner);
- Expect.equals(b, cZBoundTypeVariable.owner);
- Expect.equals(b, bZBoundTypeArgument.owner);
- Expect.equals(c, cZBoundTypeArgument.owner);
-
- Expect.notEquals(bZ, cZ);
- Expect.equals(bZ, bZBoundTypeArgument);
- Expect.equals(cZ, cZBoundTypeArgument);
- Expect.equals(bZ, bZBoundTypeVariable);
- Expect.equals(bZ, cZBoundTypeVariable);
-}
-
-testD() {
- ClassMirror cm;
- cm = reflectClass(D);
- Expect.equals(3, cm.typeVariables.length);
- var values = cm.typeVariables;
- values.forEach((e) {
- Expect.equals(true, e is TypeVariableMirror);
- });
- Expect.equals(#R, values.elementAt(0).simpleName);
- Expect.equals(#S, values.elementAt(1).simpleName);
- Expect.equals(#T, values.elementAt(2).simpleName);
-}
-
-void testE() {
- ClassMirror e = reflectClass(E);
- TypeVariableMirror eR = e.typeVariables.single;
- ClassMirror mapRAndHelperOfString = eR.upperBound;
-
- Expect.isFalse(mapRAndHelperOfString.isOriginalDeclaration);
- Expect.equals(eR, mapRAndHelperOfString.typeArguments.first);
- Expect.equals(reflect(new Helper<String>()).type,
- mapRAndHelperOfString.typeArguments.last);
-}
-
-void testF() {
- ClassMirror f = reflectClass(F);
- TypeVariableMirror fZ = f.typeVariables[0];
- ClassMirror fZBound = fZ.upperBound;
- ClassMirror fZBoundTypeArgument = fZBound.typeArguments.single;
-
- Expect.equals(1, f.typeVariables.length);
- Expect.isFalse(fZBound.isOriginalDeclaration);
- Expect.isFalse(fZBoundTypeArgument.isOriginalDeclaration);
- Expect.equals(f, fZBoundTypeArgument.originalDeclaration);
- Expect.equals(fZ, fZBoundTypeArgument.typeArguments.single);
+import "class_mirror_type_variables_data.dart";
+import "class_mirror_type_variables_expect.dart";
+
+class RuntimeEnv implements Env {
+ ClassMirror getA() => reflectClass(A);
+ ClassMirror getB() => reflectClass(B);
+ ClassMirror getC() => reflectClass(C);
+ ClassMirror getD() => reflectClass(D);
+ ClassMirror getE() => reflectClass(E);
+ ClassMirror getF() => reflectClass(F);
+ ClassMirror getNoTypeParams() => reflectClass(NoTypeParams);
+ ClassMirror getObject() => reflectClass(Object);
+ ClassMirror getString() => reflectClass(String);
+ ClassMirror getHelperOfString() => reflect(new Helper<String>()).type;
}
main() {
- testNoTypeParams();
- testA();
- testBAndC();
- testD();
- testE();
- testF();
+ test(new RuntimeEnv());
}
« no previous file with comments | « tests/lib/mirrors/class_mirror_type_variables_expect.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698