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

Unified Diff: tests/lib/mirrors/class_mirror_type_variables_expect.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
Index: tests/lib/mirrors/class_mirror_type_variables_expect.dart
diff --git a/tests/lib/mirrors/class_mirror_type_variables_test.dart b/tests/lib/mirrors/class_mirror_type_variables_expect.dart
similarity index 72%
copy from tests/lib/mirrors/class_mirror_type_variables_test.dart
copy to tests/lib/mirrors/class_mirror_type_variables_expect.dart
index 51da82ec6618fa024d118660a0182c4322f57baf..00c51249663dd855494471f75d2b7dfe321db8fd 100644
--- a/tests/lib/mirrors/class_mirror_type_variables_test.dart
+++ b/tests/lib/mirrors/class_mirror_type_variables_expect.dart
@@ -2,30 +2,46 @@
// 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.
+// Test expectations for 'class_mirror_type_variables_data.dart'.
+
+library class_mirror_type_variables_expect;
+
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;
+
+/// The interface of [Env] is shared between the runtime and the source mirrors
+/// test.
+abstract class Env {
+ ClassMirror getA();
+ ClassMirror getB();
+ ClassMirror getC();
+ ClassMirror getD();
+ ClassMirror getE();
+ ClassMirror getF();
+ ClassMirror getNoTypeParams();
+ ClassMirror getObject();
+ ClassMirror getString();
+ ClassMirror getHelperOfString();
}
-class Helper<S> {}
-class E<R extends Map<R, Helper<String>>> {}
-class F<Z extends Helper<F<Z>>> {}
-testNoTypeParams() {
- ClassMirror cm = reflectClass(NoTypeParams);
+void test(Env env) {
+ testNoTypeParams(env);
+ testA(env);
+ testBAndC(env);
+ testD(env);
+ testE(env);
+ testF(env);
+}
+
+testNoTypeParams(Env env) {
+ ClassMirror cm = env.getNoTypeParams();
Expect.equals(cm.typeVariables.length, 0);
}
-void testA() {
- ClassMirror a = reflectClass(A);
+void testA(Env env) {
+ ClassMirror a = env.getA();
Expect.equals(2, a.typeVariables.length);
TypeVariableMirror aT = a.typeVariables[0];
@@ -36,13 +52,13 @@ void testA() {
Expect.isTrue(aTBound.isOriginalDeclaration);
Expect.isTrue(aSBound.isOriginalDeclaration);
- Expect.equals(reflectClass(Object), aTBound);
- Expect.equals(reflectClass(String), aSBound);
+ Expect.equals(env.getObject(), aTBound);
+ Expect.equals(env.getString(), aSBound);
}
-void testBAndC() {
- ClassMirror b = reflectClass(B);
- ClassMirror c = reflectClass(C);
+void testBAndC(Env env) {
+ ClassMirror b = env.getB();
+ ClassMirror c = env.getC();
Expect.equals(1, b.typeVariables.length);
Expect.equals(1, c.typeVariables.length);
@@ -78,9 +94,8 @@ void testBAndC() {
Expect.equals(bZ, cZBoundTypeVariable);
}
-testD() {
- ClassMirror cm;
- cm = reflectClass(D);
+testD(Env env) {
+ ClassMirror cm = env.getD();
Expect.equals(3, cm.typeVariables.length);
var values = cm.typeVariables;
values.forEach((e) {
@@ -91,19 +106,19 @@ testD() {
Expect.equals(#T, values.elementAt(2).simpleName);
}
-void testE() {
- ClassMirror e = reflectClass(E);
+void testE(Env env) {
+ ClassMirror e = env.getE();
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,
+ Expect.equals(env.getHelperOfString(),
mapRAndHelperOfString.typeArguments.last);
}
-void testF() {
- ClassMirror f = reflectClass(F);
+void testF(Env env) {
+ ClassMirror f = env.getF();
TypeVariableMirror fZ = f.typeVariables[0];
ClassMirror fZBound = fZ.upperBound;
ClassMirror fZBoundTypeArgument = fZBound.typeArguments.single;
@@ -114,12 +129,3 @@ void testF() {
Expect.equals(f, fZBoundTypeArgument.originalDeclaration);
Expect.equals(fZ, fZBoundTypeArgument.typeArguments.single);
}
-
-main() {
- testNoTypeParams();
- testA();
- testBAndC();
- testD();
- testE();
- testF();
-}
« no previous file with comments | « tests/lib/mirrors/class_mirror_type_variables_data.dart ('k') | tests/lib/mirrors/class_mirror_type_variables_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698