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

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

Issue 2617163002: Revert "reflectType() dynamic type arguments support (#26012)" (Closed)
Patch Set: Created 3 years, 11 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/lib.status ('k') | tests/lib/mirrors/reflected_type_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/reflected_type_generics_test.dart
diff --git a/tests/lib/mirrors/reflected_type_generics_test.dart b/tests/lib/mirrors/reflected_type_generics_test.dart
deleted file mode 100644
index 53a916a623744e05520d2970a94b25b79a26d5e2..0000000000000000000000000000000000000000
--- a/tests/lib/mirrors/reflected_type_generics_test.dart
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2016, 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.
-
-library test.reflected_type_generics_test;
-
-@MirrorsUsed(targets: "test.reflected_type_generics_test")
-import 'dart:mirrors';
-
-import 'package:expect/expect.dart';
-
-import 'reflected_type_helper.dart';
-
-class A<T> {}
-
-class P {}
-
-class B extends A<P> {}
-
-class C<K, V> {}
-
-class D<T> extends A<T> {}
-
-class E<K> extends C<K, int> {}
-
-class F<G> {}
-
-typedef bool Predicate<T>(T arg);
-
-class FBounded<S extends FBounded> {}
-
-class Helper<T> {
- Type get param => T;
-}
-
-class Mixin<T extends P> {}
-
-class Composite<K extends P, V> extends Object with Mixin<K> {}
-
-main() {
- // "Happy" paths:
- expectReflectedType(reflectType(A, [P]), new A<P>().runtimeType);
- expectReflectedType(reflectType(C, [B, P]), new C<B, P>().runtimeType);
- expectReflectedType(reflectType(D, [P]), new D<P>().runtimeType);
- expectReflectedType(reflectType(E, [P]), new E<P>().runtimeType);
- expectReflectedType(
- reflectType(FBounded, [FBounded]), new FBounded<FBounded>().runtimeType);
-
- var predicateHelper = new Helper<Predicate<P>>();
- expectReflectedType(reflectType(Predicate, [P]), predicateHelper.param); /// 01: ok
- var composite = new Composite<P, int>();
- expectReflectedType(reflectType(Composite, [P, int]), composite.runtimeType);
-
- // Edge cases:
- Expect.throws(
- () => reflectType(P, []),
- (e) => e is ArgumentError && e.invalidValue is List,
- "Should throw an ArgumentError if reflecting not a generic class with "
- "empty list of type arguments");
- Expect.throws(
- () => reflectType(P, [B]),
- (e) => e is Error,
- "Should throw an ArgumentError if reflecting not a generic class with "
- "some type arguments");
- Expect.throws(
- () => reflectType(A, []),
- (e) => e is ArgumentError && e.invalidValue is List,
- "Should throw an ArgumentError if type argument list is empty for a "
- "generic class");
- Expect.throws(
- () => reflectType(A, [P, B]),
- (e) => e is ArgumentError && e.invalidValue is List,
- "Should throw an ArgumentError if number of type arguments is not "
- "correct");
- Expect.throws(() => reflectType(B, [P]), (e) => e is Error,
- "Should throw an ArgumentError for non-generic class extending "
- "generic one");
- Expect.throws(
- () => reflectType(A, ["non-type"]),
- (e) => e is ArgumentError && e.invalidValue is List,
- "Should throw an ArgumentError when any of type arguments is not a Type");
- Expect.throws(
- () => reflectType(A, [P, B]),
- (e) => e is ArgumentError && e.invalidValue is List,
- "Should throw an ArgumentError if number of type arguments is not correct "
- "for generic extending another generic");
- Expect.throws(
- () => reflectType(reflectType(F).typeVariables[0].reflectedType, [int]));
- Expect.throws(() => reflectType(FBounded, [int])); /// 02: ok
- var boundedType =
- reflectType(FBounded).typeVariables[0].upperBound.reflectedType;
- Expect.throws(() => reflectType(boundedType, [int])); /// 02: ok
- Expect.throws(() => reflectType(Composite, [int, int])); /// 02: ok
-
- // Instantiation of a generic class preserves type information:
- ClassMirror m = reflectType(A, [P]) as ClassMirror;
- var instance = m.newInstance(const Symbol(""), []).reflectee;
- Expect.equals(new A<P>().runtimeType, instance.runtimeType);
-}
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/reflected_type_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698