Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 library test.generic_f_bounded; | |
| 6 | |
| 7 import 'dart:mirrors'; | |
| 8 | |
| 9 import 'package:expect/expect.dart'; | |
| 10 | |
| 11 import 'generics_test.dart'; | |
| 12 | |
| 13 class Collection<C> {} | |
| 14 class Serializable<S> {} | |
| 15 | |
| 16 class OrderedCollection<V> | |
| 17 extends Collection<V> | |
| 18 with Serializable<OrderedCollection<V>> {} | |
| 19 | |
| 20 typedef AbstractOrderedCollection<W> | |
| 21 = Collection<W> | |
| 22 with Serializable<AbstractOrderedCollection<W>>; | |
| 23 | |
| 24 class CustomOrderedCollection<Z> | |
| 25 extends AbstractOrderedCollection<Z> {} | |
| 26 | |
| 27 class OrderedIntegerCollection | |
| 28 extends OrderedCollection<int> {} | |
| 29 | |
| 30 class CustomOrderedIntegerCollection | |
| 31 extends CustomOrderedCollection<int> {} | |
| 32 | |
| 33 class Serializer<R extends Serializable<R>> {} | |
| 34 class CollectionSerializer extends Serializer<Collection> {} | |
| 35 class OrderedCollectionSerializer extends Serializer<OrderedCollection> {} | |
| 36 | |
| 37 main() { | |
| 38 ClassMirror collectionDecl = reflectClass(Collection); | |
| 39 ClassMirror serializableDecl = reflectClass(Serializable); | |
| 40 ClassMirror orderedCollectionDecl = reflectClass(OrderedCollection); | |
| 41 ClassMirror abstractOrderedCollectionDecl = reflectClass(AbstractOrderedCollec tion); | |
|
ahe
2013/10/15 06:56:42
Long line. More below.
| |
| 42 ClassMirror customOrderedCollectionDecl = reflectClass(CustomOrderedCollection ); | |
| 43 ClassMirror orderedIntegerCollection = reflectClass(OrderedIntegerCollection); | |
| 44 ClassMirror customOrderedIntegerCollection = reflectClass(CustomOrderedInteger Collection); | |
| 45 ClassMirror serializerDecl = reflectClass(Serializer); | |
| 46 ClassMirror collectionSerializerDecl = reflectClass(CollectionSerializer); | |
| 47 ClassMirror orderedCollectionSerializerDecl = reflectClass(OrderedCollectionSe rializer); | |
| 48 | |
| 49 ClassMirror orderedCollectionOfInt = orderedIntegerCollection.superclass; | |
| 50 ClassMirror customOrderedCollectionOfInt = customOrderedIntegerCollection.supe rclass; | |
| 51 ClassMirror serializerOfCollection = collectionSerializerDecl.superclass; | |
| 52 ClassMirror serializerOfOrderedCollection = orderedCollectionSerializerDecl.su perclass; | |
| 53 ClassMirror collectionOfDynamic = reflect(new Collection()).type; | |
| 54 ClassMirror orderedCollectionOfDynamic = reflect(new OrderedCollection()).type ; | |
| 55 ClassMirror collectionWithSerializableOfOrderedCollection = orderedCollectionD ecl.superclass; | |
| 56 | |
| 57 Expect.isTrue(collectionDecl.isOriginalDeclaration); | |
| 58 Expect.isTrue(serializableDecl.isOriginalDeclaration); | |
| 59 Expect.isTrue(orderedCollectionDecl.isOriginalDeclaration); | |
| 60 Expect.isTrue(abstractOrderedCollectionDecl.isOriginalDeclaration); | |
| 61 Expect.isTrue(customOrderedCollectionDecl.isOriginalDeclaration); | |
| 62 Expect.isTrue(orderedIntegerCollection.isOriginalDeclaration); | |
| 63 Expect.isTrue(customOrderedIntegerCollection.isOriginalDeclaration); | |
| 64 Expect.isTrue(serializerDecl.isOriginalDeclaration); | |
| 65 Expect.isTrue(collectionSerializerDecl.isOriginalDeclaration); | |
| 66 Expect.isTrue(orderedCollectionSerializerDecl.isOriginalDeclaration); | |
| 67 | |
| 68 Expect.isFalse(orderedCollectionOfInt.isOriginalDeclaration); | |
| 69 Expect.isFalse(customOrderedCollectionOfInt.isOriginalDeclaration); | |
| 70 Expect.isFalse(serializerOfCollection.isOriginalDeclaration); | |
| 71 Expect.isFalse(serializerOfOrderedCollection.isOriginalDeclaration); | |
| 72 Expect.isFalse(collectionOfDynamic.isOriginalDeclaration); | |
| 73 Expect.isFalse(collectionWithSerializableOfOrderedCollection.isOriginalDeclara tion); | |
| 74 | |
| 75 TypeVariableMirror rFromSerializer = serializerDecl.typeVariables.single; | |
| 76 ClassMirror serializableOfR = rFromSerializer.upperBound; | |
| 77 Expect.isFalse(serializableOfR.isOriginalDeclaration); | |
| 78 Expect.equals(serializableDecl, serializableOfR.originalDeclaration); | |
| 79 Expect.equals(rFromSerializer, serializableOfR.typeArguments.single); | |
| 80 | |
| 81 typeParameters(collectionDecl, [#C]); | |
| 82 typeParameters(serializableDecl, [#S]); | |
| 83 typeParameters(orderedCollectionDecl, [#V]); | |
| 84 typeParameters(abstractOrderedCollectionDecl, [#W]); | |
| 85 typeParameters(customOrderedCollectionDecl, [#Z]); | |
| 86 typeParameters(orderedIntegerCollection, []); | |
| 87 typeParameters(customOrderedIntegerCollection, []); | |
| 88 typeParameters(serializerDecl, [#R]); | |
| 89 typeParameters(collectionSerializerDecl, []); | |
| 90 typeParameters(orderedCollectionSerializerDecl, []); | |
| 91 | |
| 92 typeParameters(orderedCollectionOfInt, [#V]); | |
| 93 typeParameters(customOrderedCollectionOfInt, [#Z]); | |
| 94 typeParameters(serializerOfCollection, [#R]); | |
| 95 typeParameters(serializerOfOrderedCollection, [#R]); | |
| 96 typeParameters(serializerOfOrderedCollection, [#R]); | |
|
gbracha
2013/10/15 00:28:24
This is a duplicate
rmacnak
2013/10/15 17:22:39
Fixed.
| |
| 97 typeParameters(collectionWithSerializableOfOrderedCollection, []); | |
| 98 | |
| 99 typeArguments(collectionDecl, []); | |
| 100 typeArguments(serializableDecl, []); | |
| 101 typeArguments(orderedCollectionDecl, []); | |
| 102 typeArguments(abstractOrderedCollectionDecl, []); | |
| 103 typeArguments(customOrderedCollectionDecl, []); | |
| 104 typeArguments(orderedIntegerCollection, []); | |
| 105 typeArguments(customOrderedIntegerCollection, []); | |
| 106 typeArguments(serializerDecl, []); | |
| 107 typeArguments(collectionSerializerDecl, []); | |
| 108 typeArguments(orderedCollectionSerializerDecl, []); | |
| 109 | |
| 110 typeArguments(orderedCollectionOfInt, [reflectClass(int)]); | |
| 111 typeArguments(customOrderedCollectionOfInt, [reflectClass(int)]); | |
| 112 typeArguments(serializerOfCollection, [collectionOfDynamic]); | |
| 113 typeArguments(serializerOfOrderedCollection, [orderedCollectionOfDynamic]); | |
| 114 typeArguments(collectionWithSerializableOfOrderedCollection, []); | |
| 115 } | |
| OLD | NEW |